Install the packages.
$ npm i
Install the requirements.
$ npm run dev:requirements
-
This project separates
prettier
just for formatting andeslint
just for linting, as it's advised by the developers. That's why I don't useeslint-plugin-prettier
-
When you commit something,
husky
,mrm
andlint-stage
are set to runprettier
,eslint
andjest
.
This will fix everything and let you know if you forgot about any error.
It will also run tests that were created or modified. -
Every time you update the
openapi.yaml
file, you need to run thenpm run update:openapi
script, to keepopenapi-schema.d.ts
updated, so you can use the openapi's schemas as types for this application. -
The
error-handler.middleware
will handle all errors, this also includes any unknown routes by theopenapi.yaml
and the errors thrown by the classesDomainError
andAxiosRequestError
.
WhenNODE_ENV
is set toproduction
. It will NOT interfere with the logs, but will change the error response to:
http status 500
and the body response to:Something bad happened
Unless it's aDomainError
that the client must know about! -
Unknown exceptions by the application, will use the Erlang's let it crash philosophy.
Basically it lets the app crash so the orchestrator can restart the application.
But how this really works?
First the app will stop receiving request, then finish the requests that were already in progress and gracefully shuts down everything.
This approach improves system reliability.
If you're on Kubernetes, you can use Ingress or other load balancer strategies for your application. -
There's a
rateLimiter
method configured to limit request per user's ip.
You can delete it if you decide to use this project as a private API. -
dotenv is set just for Jest.
For development it uses--env-file ./environments/.env
-
Inside the
tsconfig.json
underpaths: {}
you can set custom paths.
You don't need to set them anywhere else, this project already does that for you. -
There are two debuggers configured with auto reload to facilitate your workflow.
So you don't need to keep restarting your debugger manually.
One for Node and the other for Jest. -
You can run/debug just one test at a time with the extension
Jest Runner
from the authorfirsttris
The project is already set to run it without any problems.
PS: I've found a bug in this extension on linux, but the bug just occurs if you set yourit(``, () => {})
with template strings that has multiple lines. The bug happens when the first line has a similar description with another test before the line breaks.
Besides that it works great!
- Unit tests