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 iIt'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:devUsed in CI/CD; code quality using EsLint with several plugins
npm run lint
npm run security:auditHere'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-serverthat serves thedb.jsoncontent on theroutes.jsonroutes from thetest/integration_tests/mock_apifolder
run the mock api
npm run mock:apirun the tests
npm run test
# OR
npm run test:unit
npm run test:integrationswagger: http://127.0.0.1:8080/docs