Started for use in a friend group, this project is both a very minimal quote DB and a nice PoC for Nuxt3 + Prisma with an API and JWT authentication.
[x] Database schema
[x] Quote CRUD
[x] Invite & register
[x] User interface
[x] List quotes
[x] Log in & register
[ ] Edit quotes
[ ] Complete README
[x] Docker configuration
[ ] Unbodge
[ ] Use native store instead of bodged cookie store for state persistence
[ ] Make a proper API client
The database does not contain any data out of the box. You also don’t need an invite token to create the first user account.
The API is used internally, but may also be used by 3rd party applications.
Lists all quotes if authenticated; only public quotes otherwise
Returns quote referenced by :id (if public or authenticated)
Creates a new quote
Updates the quote referenced by :id
Deletes the quote referenced by :id
Returns the profile of the authenticated user
Verifies the received credentials and returns a JWT token if successful
Creates an account using an invite token; returns a JWT token if successful
Creates an invite token (up to 5 per user)
The API uses Bearer authentication with JWT tokens.
The table below explains the authentication/authorization indications in the endpoints table.
Only authenticated access
Only author can perform action
Partial unauthenticated access
Only unauthenticated access
First of all, check out the Nuxt 3 documentation. Keep in mind this version of the framework is in beta.
Copy example.env -> .env and make changes where necessary.
To create/update the database schema, run Prisma migrate:
npx prisma migrate dev
In order for this to work, the configured database user needs permission to connect and to query and alter tables.
Start the development server on http://localhost:3000
Build the application for production:
You can also test migrations in production mode using:
npx prisma migrate deploy
Again, the configured database user needs to have permission to alter the DB schema in order for Prisma to work.
Deployment on Docker
The docker configuration in this repository is made for the following environment:
An nginx-proxy (with acme-companion) container handles incoming HTTP traffic and certificates, and is reachable via a docker network named web.
A Postgres database is reachable via a docker network named postgres; its URL and credentials for it are set in the DATABASE_URL variable in .env.
The specified database user needs to be able to connect and to alter the database schema.
The JWT_SECRET is set in .env.
Of course you can deviate from this if you want to run this project yourself.
On startup, the container runs migrations and then starts the server.