-
Node v8+
-
NPM v6+
-
Postgres v10+
-
Migra
pip install --user migra[pg]
-
jq (Development dependency for readable development logs)
-
NPM dependencies
npm i
Copy the .env.example
file to .env
and modify as necessary.
-
Create the user, the database, and the helper database. Make sure the new user is the owner of the public schema of the helper database.
Exact commands depend on the Postgres installation and the environment. Here are example commands that would work for a Postgres superuser:
createuser factlist createdb factlist -O factlist createdb factlist_next -O factlist psql factlist_next -c 'alter schema public owner to factlist'
-
Migrate the database. See the migration section below.
-
Optionally seed the database:
npm run db:seed
-
Edit the database schema file (Skip this if first time migrating)
-
Generate a migration script:
npm run db:diff
-
Review the generated script, modify as necessary, then apply:
npm run db:patch
-
See Migra and state driven database delivery for more information on this kind of approach to migrations.
Documentation is powered by the Fastify Swagger plugin which automatically generates an OpenAPI v2 specification from the app's route declarations.
To see the docs go to http://$HOST:$PORT/documentation
in your
browser when the server is running.
-
Start the server:
npm start
- After adding a new route or modifying the schema of a route; Fastify Swagger sometimes causes the server to crash, and it can't recover despite Nodemon. Just kill the Nodemon process and start it again in that case.
TODO