This project enables the development of APIs with NodeJS.
curl https://github.com/chainhead/scaffold/ | bash
- The logging mechanism in this project outputs a time-stamp. To ensure that, the timestamp matches a specific timezone, the operating system must expose timezone for
moment.js
to consume. Typically, this happens with aTZ
environment variable set to e.g.Asia/Kolkata
. - All configuration is pushed as a JSON object from an environment variable
APP_CONFIG
. This variable name maybe changed as required. TODO: Support for configuration files instead of environment variables.
- The design decision for securing the communication betwen this server and a client is to have TLS communication terminated before it hits this server. Such a TLS termination maybe done with e.g.
Nginx
where, load balancing may also be set-up.
Launching of an application can be one of the following ways:
- Deployed as a project on a VM with
pm2
. - Deployed as a Docker container.
- Deployed to a OpenShift cluster with build as:
- Source to Image
- Docker
- Pipeline
The following guidelines changes may be applied for project files.
- Change
logger.info
message inrun()
for different message before starting up the server. - During start-up,
index.js
will establish connection to a cache (e.g. Redis) incache/connect.js
and a authorisation server (e.g. LDAP) inauth/connect.js
. If more connections are needed then, create the following as shown in examples below. The connection configuration should be added into theAPP_CONFIG
environment variable.db/connect.js
- For connecting to an RDBMS e.g. Postgresmsg/connect.js
- For connecting to a messaging system e.g. Kafka
- More middleware maybe added as required.
- Each middleware maybe edited as required.
- For an end-point such as
app.get('/services)
, the following is expected: Note that, the file name matches the REST resource to enable traceability.mw/mservices.js
- Payload specific checks.routes/rservices.js
- Entry-point for business logic.utils/uservices.js
- Helper functions for business logic.cache/cservices.js
- Cache queries (CRUD) to be invoked by any of the above.