- nodejs 14.x, 16.x - this project supports
.tool-versions
via asdf - mongodb 4.0, 4.2
- docker - Start Up contains instructions for installing mongo via docker
- To get started run
npm run init
(if you do not have mongo running usenpm run init:mongo
)- This will install the dependencies and setup the
development.js
environment from the template
- This will install the dependencies and setup the
- Start the application via
npm start
init
- initalizes projectinit:mongo
- initalizes project and runs mongodb via dockerinit:env:dev
- copies development environment config template to usable locationinit:mongo:up
- uses docker compose to run containerized mongodbinit:mongo:express
- uses docker compose to run mongo express at http://localhost:8081 for mongo debugginginit:mongo:down
- removes node-rest-starter docker container groupstart
- runs project and watches for changes and reloadsstart:dev
- runs with node_env set to developmentstart:prod
- runs compiled version of project
Endpoint Documentation for this application is generated from the *.routes.js
files in each module.
Model/Schema documentation should be included in with each model and will be compiled from any file matching *.model.js
.
When the application is started, Swagger provides an interface for this API that is available by default at http://localhost:3000/api-docs
The existence and path for this Swagger page is configurable via the apiDocs
parameter, which defaults to:
{
"enabled": true,
"path": "/api-docs"
}
Several services use configurable "providers" in order to easily swap functionality in and out of the application.
For example, the Email Service at ./src/app/core/email/email.service.ts
can be controlled via the mailer.provider
configuration to use any of the out-of-the-box providers:
- HTTPS
- SMTP
- Log
- File
- Noop
The default provider for a service will be included in dependencies
in NPM's package.json
. On the other hand, any non-default providers should include their dependencies as devDependencies
in order to reduce the inclusion of unnecessary modules in production builds.
If a non-default provider is used (e.g., node-kafka
for the Event
service), the application instance should include this module in dependencies
on its own fork, instead of updating the node-rest-starter
reference application.
Tests run as an NPM script. To support development, npm run test
will watch all files via nodemon
and will run tests as files are updated.
In order to generate code coverage output via a single run of the test suite, npm run test:ci
will output coverage results into the top-level ./coverage
directory, both in HTML and LCOV formats.
Since Mongoose suggests not automatically creating Mongo indices on-the-fly, the following utility script can be run, targeting the production Mongo instance / cluster, to create/sync all required indices.
node ./src/sync-indexes.js