A fullstack starter for little projects requiring authentication and user management. Based on express, passport, knex and lit, automatically packed into a docker container using a github action.
The frontend was generated using npm init @open-wc.
The backend was generated using npx express-generator.
During the docker build, the frontend build is copied from frontend/dist to backend/public, from where express serves static files. The backend is then wrapped up into the official lts-slim node image from dockerhub. Knex is configured to use better-sqlite3 in knexfile.js. If used in a docker container, the following environmental parameters are available:
- ADMIN_USERNAME (only changed if no admin exists in the database yet, defaults to "admin")
- ADMIN_PASSWORD (only changed if no admin exists in the database yet, defaults to "admin")
- SESSION_SECRET (Using a secret that cannot be guessed will reduce the ability to hijack a session, see here)
For development, execute
npm run init
in order to create a database for development purposes and create one admin (password "admin") and one user (password "user").
npm start
This will serve the frontend using @web/dev-server on port 8000 and the backend using nodemon on port 3000, both watching for file changes and restarting the backend or reloading the web page on every file change. The frontend dev-server is configured to forward all calls to /api/ to the backend port.
All this is configured on Linux, I am sure you need several changes in the package.json files for development on Windows.