This repository contains the API, database and other core infrastructure needed for the "backend" of all clients, e.g. the mobile app and website.
All documentation for Nationskollen is available here.
npm install
- Setup the database as described below (for your chosen database)
npm run dev
The API will now be available at localhost:3333
.
During development you can use either SQLite3 or PostgreSQL. Note that SQLite3 does not support datetime filtering and event filtering does not work. Because of this, the default database is PostgreSQL.
Set DB_CONNECTION
to sqlite
in .env
. Now everything should work as
expected.
Before starting the database, make sure the following is installed:
- docker
- docker-compose
- Have the Docker Desktop application running while executing commands in the terminal.
Install the dependencies and make sure that the docker service is running (e.g.
by enabling the docker daemon in systemd services or by starting Docker Desktop)
and start the PostgreSQL container using npm run pg:start
.
If you want to stop the container you can run npm run pg:stop
.
Note that you will most likely need to prefix the
pg:start
andpg:stop
commands withsudo
to be able to start the container.
Before you can start the server using npm run dev
you must run migrations and
seeders using npm run setup
. Note that this is not required to run tests,
since it will automatically do this.
npm run pg:start
- Starts the PostgreSQL database in dockernpm run pg:stop
- Stops the PostgreSQL database docker containernpm run setup
- Run database migrations and seedersnpm run build
- Build the application for productionnpm run start
- Start the server in production modenpm run dev
- Start the server in development modenpm run lint
- Run ESLint on all source filesnpm run format
- Format all source files using Prettiernpm run test
- Run all tests defined intest/
npm run coverage
- Get test coverage as HTML incoverage/index.html
npm run docs
- Generate documentationnpm run docs
- Generate documentation and watch for changes
Insomnia can be setup by importing the workspace file in
.insomnia/Workspace/nationskollen.json
. Tokens are auto-generated and will be
inserted automatically when making authenticated requests.