Backend

Backend

Installation with Docker

Run the following command to install everything through docker.
The installation takes a bit longer on the first pass or on rebuild ...
1
$ docker-compose up
2
3
# rebuild the containers for a cleanup
4
$ docker-compose up --build
Copied!
Wait a little until your backend is up and running at http://localhost:4000/.

Installation without Docker

For the local installation you need a recent version of node (>= v10.12.0).
Install node dependencies with yarn:
1
$ cd backend
2
$ yarn install
Copied!
Copy Environment Variables:
1
# in backend/
2
$ cp .env.template .env
Copied!
Configure the new file according to your needs and your local setup. Make sure a local Neo4J instance is up and running.
Start the backend for development with:
1
$ yarn run dev
Copied!
or start the backend in production environment with:
1
yarn run start
Copied!
For e-mail delivery, please configure at least SMTP_HOST and SMTP_PORT in your .env configuration file.
Your backend is up and running at http://localhost:4000/ This will start the GraphQL service (by default on localhost:4000) where you can issue GraphQL requests or access GraphQL Playground in the browser.
GraphQL Playground

Database Indices and Constraints

Database indices and constraints need to be created when the database and the backend is running:
Docker
Without Docker
1
docker-compose exec backend yarn run db:migrate init
Copied!
1
# in folder backend/
2
# make sure your database is running on http://localhost:7474/browser/
3
yarn run db:migrate init
Copied!
Seed Database
If you want your backend to return anything else than an empty response, you need to seed your database:
Docker
Without Docker
In another terminal run:
1
$ docker-compose exec backend yarn run db:seed
Copied!
To reset the database run:
1
$ docker-compose exec backend yarn run db:reset
2
# you could also wipe out your neo4j database and delete all volumes with:
3
$ docker-compose down -v
4
# if container is not running, run this command to set up your database indeces and contstraints
5
$ docker-compose run backend yarn run db:migrate init
Copied!
Run:
1
$ yarn run db:seed
Copied!
To reset the database run:
1
$ yarn run db:reset
Copied!

Data migrations

Although Neo4J is schema-less,you might find yourself in a situation in which you have to migrate your data e.g. because your data modeling has changed.
Docker
Without Docker
Generate a data migration file:
1
$ docker-compose exec backend yarn run db:migrate:create your_data_migration
2
# Edit the file in ./src/db/migrations/
Copied!
To run the migration:
1
$ docker-compose exec backend yarn run db:migrate up
Copied!
Generate a data migration file:
1
$ yarn run db:migrate:create your_data_migration
2
# Edit the file in ./src/db/migrations/
Copied!
To run the migration:
1
$ yarn run db:migrate up
Copied!

Testing

Beware: We have no multiple database setup at the moment. We clean the database after each test, running the tests will wipe out all your data!
Docker
Without Docker
Run the jest tests:
1
$ docker-compose exec backend yarn run test:jest
Copied!
Run the cucumber features:
1
$ docker-compose exec backend yarn run test:cucumber
Copied!
Run the jest tests:
1
$ yarn run test:jest
Copied!
Run the cucumber features:
1
$ yarn run test:cucumber
Copied!
Last modified 1yr ago