prerequisite:
- node lts (16.x or 18.x) with nvm it will be setted automatically
- MongoDb
Install dependencies:
npm ciConfigure the .env file
- copy
.env.templateto.env - update the value of
MONGO_URI
Start in developpement with auto-restart
npm run start:devStart in production mode
npm run start:productionUnit and integration tests will run at the same time. All database accesses use an in memory mongodb.
npm test- The code base is style using prettier.
- A pre-commit hook will apply the styling on every commit.
- Commit messages must follow the conventional commits standard.
- Verified using a commit-msg hook
- Automatic change logs can be generated
npm run release
- Validation uses class-validator and can be verified using the
validationGuardfound in thesrc/core/validationfolder.
- Dependencies should be injected, the main configuration is done in
src/app.ts. - In the future, injection should implement a correct DI container.
- I'd recommend using
reflect-metadatato build that logic. - Or using a framework like NestJs, it's just a wrapper around express offering a very performant DI system and a lot of other utilities
- Mongodb is used to allow easy extension on the models and at the moment no strict relations between entities must be guaranteed.
- If this constraints comes around I'd recommend typeorm.
- Typeorm would allow a setup with mongodb and then switch to a relational database.
- Configuration use dotenv in development
- Configuration use en variable for production
- If a vault is needed, it can be setted up inside the configuration classes
- Tests are not stored in the
srcfolder to reduce the production artifact src/configshould hold configuration logicsrc/coreshould contain only purely technical functions/classes used in the business logic modules/foldersrc/:module-nameshould follow a Domain Driven architecture to enhance logic readabilitymain.tsis used to start the express server and inject configurationapp.tsis used to configure the express app, controller and services injection are done here (for the moment)
- unit tests are used for TDD mainly
- coverage in gained using integration tests
- both test are ran using an in memory mongodb
npm testshould run both tests suites
- uses
consolefor the basic version - A proper logger need to be added.
- It should at least offer a configuration to excludes log by level of criticity by environnement and the possibility to send logs to a external logging services that allow structured logs.
- not implemented at the moment
- Should be setted up