nstuyvesant / sveltekit-auth-example

SvelteKit Authentication Example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Congratulations and further contributions

gil-obradors opened this issue · comments

Great example!

I have some questions:

  • From a learning view, why do you use db procedures and functions instead of NodeJS code? Do you recommend it in a production environment?
  • I could contribute with my knowledge adding: docker, kubernetes and finally ( stil discovering) k8s-ingress with security ( rate-limits endpoints)

Thanks! There are three schools of thought with regard to the database interface:

  1. Use an object relational mapping node library like sequelize to reduce dependence on a specific SQL database and to handle migrations. Pros: database independence, make all the code JavaScript/TypeScript, easy migrations. Cons: minor performance impact.
  2. Write database-optimized code as I've done in this example. Pros: very high performance and allows an abstraction layer between the database structure and the code in the endpoints via views, stored procedures and functions. Cons: no easy way to handle migrations.
  3. Use a no SQL database like Mongo. Pros: all JavaScript/TypeScript code and high performance. Cons: certain scenarios favor PostgreSQL. Your mileage may vary.

All are valid approaches for production. I like #2 because I use Heroku which offers PostgreSQL as an option. I like giving the database server some work to do to keep the node processing overhead down.

Contributions to this project would be very welcome. I could see there being variations showing other approaches.

In regard to nr 2's migration management. I just stumbled on https://sqitch.org/. I have not tried it yet... But if it does what I think it does, I will be very happy.

Migrations are the main obstacle for approach 2 so that product looks like a nice way to overcome it (if it works well).