Libraries used:
- typescript + es6/es7
- express.js
- winston.js for logging
- gulp as task runner
- inversify.js as dependency injector
- apidoc/tsdoc for API/code documentation
- mocha for tests
Make sure to have node.js installed (node 8+ and npm 5+ recommended).
If unsure, use nvm:
nvm install
nvm use
Install missing dependencies:
npm install
Compile the project with:
npm run build
or using the build task in vscode
node release/js/bin/httpApi.js
npm start
pm2 start ecosystem.json
npm run watchApi
You can debug manually using node-inspector or the legacy node REPL, or by using the vscode debugger.
A vscode launch.json config file is included in the repo.
Build the API documentation with:
npm run apidoc
The docs are compiled into docs/ folder and they can be served with
node release/js/bin/apiDocs.js
The default port is 16020 (override it by setting the PORT env variable)
Deploy specific configs are stored in config/default.json
and config/{{env}}.json
They are read using config.js library.
The schema and the default config can be found in src/core/config.ts
Some basic e2e tests are included. Run them with:
npm run test
It is possible to change some variables for the test environment only (i.e. port, log level) by editing/creating config/test.json
, i.e.:
{
"api":{
"port": 17011,
"log": {
"http": false,
"error": true,
"level": "info"
}
}
}
Configuration files for Visual Studio Code
Deploy specific config, stored in config/default.json
and config/{{env}}.json
.
custom-environment-variables.json
is used to map environment variables to configuration fields.
API documentation built using apidoc.js library and apidoc npm task
Code for the HTTP APIs
route.js
is the main bootstrap of the routes
endpoints for the API (i.e. /user, /product etc.).
Every endpoint has a controller, a route configuration and a test file.
Folder for the main runnable binaries.
Every binary usually fetch the config files, instantiate the main classes using inversify.js and run the server.
Main classes for the backend
database models (only stock in this case)
Injectable services
(Non Injectable) utility functions