Minimal REST API server using Express.js 5, Kysely, and SQLite3. Written in TypeScript with strict ESLint rules.
- Node.js 22+
- Install dependencies:
npm install - Create a
.envfile with the required environment variables (seeconfig/config.tsfor available options):DB— SQLite database file path (default:./dbdev.sqlite3.db)NODE_ENV—developmentorproduction(default:development)
- Run migrations to initialize the database:
npm run migrate - Start the server:
- Production (compiled):
npm start - Development (via tsx):
npm run dev
- Production (compiled):
- Call the API endpoint:
curl http://localhost:3000/persons
The http/ folder contains JetBrains HTTP Client files:
http/api.http— ready-to-run requests for every endpoint (list, get, filter, sort, paginate, create)http/http-client.env.json— environments fordev(localhost:3000) anddocker(localhost:4000)
Open http/api.http in any JetBrains IDE, pick the environment from the dropdown, and run individual requests from the gutter icons.
Migrations are managed via Kysely's built-in Migrator API.
# Run all pending migrations (includes schema + seed data)
npm run migrate
# Roll back the last migration
npm run migrate:down
# Roll back all migrations
npm run migrate:resetMigrations live in migrations/ as TypeScript files and are executed via tsx.
- Make sure dependencies are installed
- Run
npm test
Tests use .env.test (SQLite :memory:) and run sequentially (--test-concurrency=1) because all test files share a singleton Kysely instance.
node:test— built-in test runner (Node 22+)expect— standalone assertion library (Jest-style)supertest— HTTP-level integration testingc8— V8 coverage reporting
npm run lint # Check for lint and type-aware errors
npm run lint:fix # Auto-fix lint issues where possiblenpm run build # Compiles TypeScript to dist/ via tsc
npm start # Runs the compiled output