Killer Api.
Nest framework is used in this project.
Install global Nest CLI if not already done:
$ npm install -g @nestjs/cliThen install dependencies:
$ yarnThen create a local .env file:
$ cp .env.dist .envThis .env file is git ignored, fill it with your real local secrets.
This project use a PostgreSQL DB and Mercure on a caddy server. If you prefer, you can run them inside containers with
$ docker-compose up -dThen run knex migrations (install knex CLI before perform these actions) :
$ knex migrate:latestTo load fixtures from seeds files :
$ knex seed:run# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:covKnex is a SQL query builder.
You can download is CLI to perform some actions:
$ npm install knex -gYou can create migrations files that you have to fill:
$ knex migrate:make migration_nameRun migrations in database:
$ knex migrate:latestCreate seed file:
$ knex seed:make seed_nameSee more on Knex
Start by downloading mercure release archive on Mercure Github.
Then unzip it in a directory of your choice.
Then you can launch a mercure instance (running in a caddy server) with the follozing command, using the mercure executable you've just extracted :
$ MERCURE_PUBLISHER_JWT_KEY='killer-mercure-publisher' \
MERCURE_SUBSCRIBER_JWT_KEY='killer-mercure-subscriber' \
SERVER_NAME=:5000 \
./mercure run -config Caddyfile.devIt automatically runs mercure on port 5000. If you get an error such as forbidden on this port, just switch the port used to a free port that you are allowed to use.
Now that Mercure is running, you can subscribe to it.
Subscriptions to Mercure are performed with eventSource, and detailed in this article.
Nest is MIT licensed.