This is a Node.js server application utilizing popular libraries and tools, including:
- Express: Framework for building web applications
- Morgan: Express middleware for logging
- NoCache: Express middleware for prevent client-side caching
- Helmet: Express middleware to secure an app using HTTP headers
- CORS: Express middleware to allows cross-origin resource sharing
- Body-Parser: Express middleware to parse incoming request for handling
- Mongoose: MongoDB object modeling tool
- Logger: Logs messages to the console
- Express-Rate-Limit: Express middleware for rate limiting by IP
- Dotenv: Zero-dependency module to loads environment variables (.env)
DB_HOST=<mongodb-host>
DB_PORT=<mongodb-port>
DB_NAME=<mongodb-database-name>
DB_USER=<mongodb-user>
DB_PWD=<mongodb-password>
API_KEY=<api-key>
graph LR
A[Client] --> B[Node Express App]
B --> C[pubcode Router]
C --> D[validate API Key Middleware]
D -->|X-API-KEY valid| E[bulkLoad Service]
D -->|X-API-KEY invalid| F[401 Unauthorized response]
E -->|Success| G[200 Success response]
E -->|Failure| H[500 Internal Server Error response with error log]
C --> I[readAll Service]
I -->|Success| J[200 Success response with data]
I -->|Failure| H
C --> K[findById Service]
K -->|Success| L[200 Success response with data]
K -->|Failure| H
C --> M[health Service]
M -->|Success| N[200 Success response with count]
M -->|Failure| H