Small service implementation based on koa framework and jeffijoe boilerplate.
Expose a tiny api to manage queries to Neo4j Server.
api/login: POST request that gets connection uri, user and pass from reuqest body. With this credentials we will store a Neo4j driver in service store and return it's identifierapi/logout: GET request that receives a driver identificator and remove it from the storeapi/query: GET request that receives a driver identificator and a query to execute against Neo4j server
There are a few defined run scripts, here's a list of them with a description of what they do. To run them, simply execute npm run <script name> - e.g. npm run dev
start: Used by the production environment to start the app. This will run a compiled version, so you need to executebuildfirst.build: Runs thebabelCLI to compile the app. Files are emitted todist/.dev: Runs the app in development mode - usesbabel-nodeto compile on-the-fly. Also usesnodemonto automatically restart when stuff changes.test: Runs tests.cover: Runs tests and collects coverage.lint: Lints + formats the code.
Tip: to pass additional arguments to the actual CLI's being called, do it like in this example:
For npm:
# Note the `--` before the actual arguments.
npm run test -- --debugFor yarn:
# Yarn does not need the `--` before the actual arguments.
yarn test --debugFor running dev:
# Note: use --build only when you want to build. Usually when you change packages.json
docker-compose up --buildFor running test:
docker-compose -f docker-compose.test.yml upThe environment variables can be reached by importing lib/env.
import { env } from '../lib/env'
Additionally, all environment variables you'd usually find on process.env will be available on this object.
When attempting to access a key (env.PORT for example), if the key does not exist an error is thrown and the process terminated.
In the repository root, you will find a env.yaml, which is where you can set up environment variables so you won't have to do it from your shell. This also makes it more platform-agnostic.
The top-level nodes in the YAML-file contain a set of environment variables.
yenv will load the set that matches whatever NODE_ENV says.
I've set it up so anything in tests will override anything in development when running tests.
Actual environment variables will take precedence over the env.yaml file!
See the yenv docs for more info.
Each file in /routes exports a "controller" that awilix-koa will use for routing. Please see awilix-koa docs for more information.
This boilerplate uses the Awilix container for managing dependencies - please check out the Awilix documentation
for details. The container is configured in lib/container.js.
Middleware is located in the middleware folder and is not automatically loaded - they should be installed in lib/server.
- Adrián Insua Yañez - @AdrianInsua
MIT.