This application is a Node.js backend template designed to provide a well-organized structure for developing RESTful APIs. It features a modular architecture with controllers, services, models, and middlewares. The app is set up to handle user authentication, and it includes a comprehensive set of utility functions for handling common tasks such as encryption, validation, and rendering responses.
- Express.js server with a clear structure for controllers, services, models, and middlewares
- Support for user authentication with encryption, password hashing, and UUID generation
- Error handling and response rendering
- Utility functions for common tasks
- Configurable environment settings
application
: Contains application-level code, such as superclass implementations for controllers and servicesconfig
: Stores configuration settings for different environments (e.g., development, production)controllers
: Holds the application's controller files, responsible for handling HTTP requests and rendering responseshelpers
: Includes utility functions for various tasks, such as encryption, date manipulation, and validationmiddlewares
: Contains middleware functions for handling specific tasks, such as decrypting JWE payloads or printing HTTP responsesmodels
: Defines data models and related methods for interacting with the application's data storeservices
: Holds service classes that handle the business logic of the application
- Clone the repository
- Run
npm install
to install dependencies - Set the environment variables as needed (e.g.,
NODE_ENV
) - Start the server with
npm start
The application includes several endpoints for testing and demonstration purposes. These endpoints can be accessed through the /mocha
route:
GET /mocha/get/200
: Returns a 200 OK response with aget
payloadPOST /mocha/post/201
: Returns a 201 Created response with apost
payloadPUT /mocha/put/202
: Returns a 202 Accepted response with aput
payloadPATCH /mocha/patch/202
: Returns a 202 Accepted response with apatch
payloadDELETE /mocha/del/204
: Returns a 204 No Content responseGET /mocha/get/401
: Returns a 401 Unauthorized response
Additionally, the app includes user authentication endpoints:
POST /user/signup
: Creates a new user with a username and encrypted passwordPOST /user/signin
: Authenticates a user with their username and password