A Clean Architecture template for a Rest API in typescript
Motivations, explanations, requirements & more details in my article Practical Clean Architecture in Typescript, Rust & Python
npm i
It's currently configured to run with PostgreSQL through TypeOrm (ORM), but this being clean architecture feel free to change it :)
I suggest
create the databases (dev & test) based on the .env.<env>
config files.
The synchronize
option is set to true in the TypeOrm connection configuration, so it'll automatically create the data model (and update it).
define the environment on which we're running by adding ENV=<env>
, which will use the .env.<env>
file
However, I'd suggest to use the npm scripts
npm run run-ts:dev
Used in CI/CD; code quality using EsLint with several plugins
npm run lint
npm run security:audit
Here's what done in order to mock the SPI
- db: yml fixtures to insert test data in the test database, using
typeorm-fixtures-cli
- http: create a fake api using
json-server
that serves thedb.json
content on theroutes.json
routes from thetest/integration_tests/mock_api
folder
run the mock api
npm run mock:api
run the tests
npm run test
# OR
npm run test:unit
npm run test:integration
swagger: http://127.0.0.1:8080/docs