Skip to content

Latest commit

 

History

History
41 lines (26 loc) · 1.67 KB

README.md

File metadata and controls

41 lines (26 loc) · 1.67 KB

Pat's API boilerplate

js-standard-style CI Status

Shit included:

  1. Fastify as the API server (fast and comes with Pino out of the box)
  2. AVA and supertest for testing
  3. Flow for totally optional type annotations
  4. Standardjs and Prettier for never-think-of-it-again code formatting

Design

The thing is designed to be simple but extendable.

For example:

  • Fastify makes the service very lightweight and fast. Just add routes under the /routes folder and app.register(myRoute) them in app.js or whatever.

An example route is the /healthCheck one, which also has an integration test (see below), and can be used to report service health to some monitoring solution.

  • config.js holds all app-level configuration the rest of the app could use. The whole config object can be overridden at launch/deployment time using a CONFIG environment variable.

  • Write some bloody tests, man. Ava is super simple and I have added examples for unit and integration tests.

npm run test for unit tests npm run test:int for integration tests

  • The built-in logger is doing a few convenience tasks, but is really just a thin wrapper around pino. It outputs logs in JSON, ready for ELK or other centralised monitoring.

That's it. Now go build your shit.

Todo:

  • Dockerfile and docker-compose config
  • K8s service definitions
  • Some CI config
  • Migrate from Flow to Typescript?
  • Replace Koa with Fastify
  • Add Serverless config for Lambda deployment