Basic structure for Node.JS RESTful API with Bearer
and Basic
authorization, logs, multithreading and zero downtime modules restart. Based on Restify.
npm install
- install all required Node.JS modulesnpm start
- run API
Main config is inside config/config.js
, following modules are manadatory:
docs
- generate docs with menu and anchors based on MD filesstatic
- handle static files throught Restify APImaintenance
- module/method for restart API threads and clear classes cache
API support two methods for authorization.
curl -v -H "Authorization: Bearer hello" http://127.0.0.1:8081/demo/123/
curl -v -u demo:123 http://127.0.0.1:8081/demo/1/
There is only one example method /demo/:id/
that will return the same ID
if it greater than zero or error. Example above.
API modules (for ex. after update) could be restart without complete restart of API server. To make this possible every thread shut down one by one and respawn again after clearing cache with modules.
curl -v -H "Authorization: Bearer hello" http://127.0.0.1:8081/maintenance/restart/