This repository contains use cases code samples based on koa-template.
I will try to create an article for each codes samples to explain why I choose to implement things like this. I will add links to these articles in this README.md when they will be published.
- Illustrate dependencies injections with koa-depsi to simulate DB failures in your tests. See article
- Clean error management with : verror. See article
- Payload validation with AJV through koa-validator-ajv
- Testing your API with operations on the database
- Testing routes that performs HTTP calls to externals services with nock
- Implement a good SQL transaction management with PostgresSQL pg
- run :
npm run doc
- open
./apidoc/index.html
to read the documentation
- run :
npm install
- run test in docker containers :
npm run test:docker
This will run the tests and relaunch the tests if files are changing. - run test locally :
npm test
You will need to have a postgresSQL on localhost. You can use the docker created by thenpm run test:docker
command.
- run API server locally with docker :
npm run start:docker
After running npm test
you can access the code coverage report here : ./coverage/index.html