edwardspresume / sveltekit-lucia-auth-v3-example

This example project showcases how to integrate Lucia V3 for user authentication in a SvelteKit application. User data is stored in a local SQLite database
MIT License
45 stars 4 forks source link

use postgres #1

Closed digitalit closed 9 months ago

digitalit commented 9 months ago

Hi,

I'm trying to use postgres instead of sqlite but i can't figure it out.

Any tip?

Have a nice day

edwardspresume commented 9 months ago

Hi Peter,

Pardon the delay, just saw your message a few minutes ago. Are you trying to run your postgres DB locally and are you trying to use it with drizzle?

Also, just a heads-up I started a new job this week, so I might not be able to look into this in depth till later this week as I settle in

And thank you, have a nice day as well !

digitalit commented 9 months ago

Hi Edward,

Your answer were blazing fast so no need to apologize.

Yes, i intend to use drizzle and a local PG for dev and maybe Vercel with PG for production.

I found this repo: https://github.com/ak4zh/slide/tree/main that works fine but there are som differences from yours regarding schema and some other stuff.

I just want to be sure i start building with Lucia "the right way".

Congrats to the new job.

EDIT*

I just got it working: https://github.com/digitalit/sveltekit-lucia-auth-v3-example

I like your way as it's reflects the Lucia docs more in terms of schema.

Anyway take your time and please let me know what you think of my migration to PG.

Have a nice day.

edwardspresume commented 9 months ago

Thank you

And right on for getting it working! I'll take a look later today

Have a nice day

edwardspresume commented 9 months ago

Your migration to PG is good. I was able to get your repo working with PG locally. And I like the naming of the folder "migrations" since it's a lot more clear of its purpose, I'm going to be doing the same moving forward

The use of using a env for the DATABASE_URL and the error handling that you have for it in drizzle.config.ts is also a nice touch. I was too lazy to add it to mine 😅

Also note that the --config option for the drizzel-kit commands is not required if the drizzle config file is named drizzle.config.ts as this is the default file that drizzle read. But it's good that you specified that option, in case the drizzle team ever change the default name for the config file

digitalit commented 9 months ago

Please tell me if you want to continue this conversation and if so, should we continue here in a "issue"?

I want to give you some background of my situation. I used to divide a project into 3 different apps:

  1. api.customers.se - this was an API using the framework AdonisJS with purpose to only handle data, mails and media.

  2. admin.customer.se - this was the admin for my customer using the framework Quasar in SSR mode with purpose to handle all in house content and of course the content of the public customer site.

  3. www.customer.se - this was the public site for for my customers visitors using the framework Quasar in SSR mode

PROS:

  1. i could mess around with admin.customer.se and my customers public site were still up and running (unless see CONS 1)
  2. i could do updates to admin.customer.se to see if something went wrong without affecting the customers public site
  3. i could allow an external site to consume the API

CONS:

  1. i could mess around with admin.customer.se and changes could accidentally break something in the customers public site
  2. extremely time consuming managing 3 apps and furthermore 2 different frameworks that were releasing new versions faster than i could keep up
  3. really over kill since i used only a fraction of each framework.
  4. Quasar forced me to choose CSR/SSR for the whole app and not like Sveltekit that allows med to use CSR/SSR in different parts of the app
  5. Quasar uses Vue (that is a great) but i wanted to use Svelte as it feels much more logic and a more future feel to it.
  6. Quasar forced me (ish) to use Material Design witch for me is starting to feel a bit like Bootstrap felt before.
  7. and a lot more but you get that the cons is overwhelming

As you understand i'm totally new to Sveltekit/Svelte so forgive me for asking stupid questions.

  1. I wonder what the purpose with /utils/styleTransitionUtils.ts is. Is it some visual stuff or something functionally?
  2. Also i wonder why the hard redirect to dashboard if loged in? I had to comment out throw redirect(303, DASHBOARD_ROUTE); in hooks.server.ts to be able to add like /routes/dashboard/todos
  3. i see that some repos has splited the user table extracting the user password into a separate table like key. Any thoughts on that?

Have a nice day