SvelteKit Tendaro webshell skeleton
Status : work in progress.
This project is a spin-off of sveltekit-user-auth-postgres-rls-skeleton
.
Repository starting point issue (in French): stephane-klein/backlog#313
Note: this project is not a real "skeleton", I don't propose a script to replace the project name, variables... I can qualify this project as a "static" example that I can use as a skeleton.
Opinions:
- No ORM pattern
- The security layer, i.e. permission control is implemented by PostgreSQL Row-Level Security
impersonate_user_id
is stored inauth.sessions
table (this can be challenged)- I'm trying to move towards Radical Simplicity
- Don’t Build A General Purpose API To Power Your Own Front End
- The page rendering spped, and therefore the execution speed of SQL queries, needs special attention
Components and libraries:
- ✅ SSR SvelteKit with Hydration
- ✅ PostgreSQL database server
- ✅ Postgres.js - PostgreSQL client for Node.js
- ✅ Migration powered by graphile-migrate
- ✅ Token generated with jsonwebtoken
- ✅ PostgreSQL Row-Level Security
- ✅ svelte-headlessui
- ✅ sveltekit-i18n
- ✅ TailwindCSS
- ✅ Tabler Icons
- ✅ Superforms
- ✅ sveltekit-flash-message + svelte-french-toast
Tooling:
- ✅ asdf
- ✅ Docker and Docker Compose
- ✅ NodeJS
- ✅ pnpm
- ✅ Jest for unittest
- ✅ tbls to generate database documentation
Getting started
$ asdf install
$ pnpm install
Start database engine:
$ ./scripts/init.sh
$ ./load-fixtures.js
Start web server:
$ pnpm run dev
Go to http://localhost:5173/
Valid logins
- email:
john.doe1@example.com
password:secret1
- email:
john.doe2@example.com
password:secret2
- email:
john.doe3@example.com
password:secret3
Create new user with:
$ pnpm run user create --email=john.doe4@example.com --username=john-doe4 --password=password --firstname=John --lastname=Doe
Maildev
You can access to Maildev on http://localhost:1080
Database migration
$ pnpm run migrate:watch
Apply migration in migrations/current.sql
and commit:
$ pnpm run migrate:commit
Start Histoire
$ pnpm run story:dev
Go to http://localhost:6006
Execute Unittest
$ pnpm run migrate-test:watch
$ pnpm run -s tests
PASS tests/auth.js
✓ Create a user (39 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.255 s, estimated 1 s
Ran all test suites.
Prettier
Launch Prettier check:
$ pnpm run prettier-check
Apply Prettier fix example:
$ pnpm run prettier src/app.html
ESlint
$ pnpm run eslint
Generate database doc
$ ./scripts/generate-database-doc.sh
Next see ./docs/database/
.