Clustering - Logging - Testing - Error/Response Handler
EXPLORE DOCS
Plenty of features
·
Report Bug
·
Request Feature
Table of Contents
This repository provides a comprehensive Node.js template designed for building robust and scalable web applications. It integrates essential features and best practices to streamline the development process. This template is fully implemented in TypeScript and includes various functionalities such as route validation, CORS, security enhancements, logging, and more.
- Express: Built with Express, a fast and minimalist web framework for Node.js.
- TypeScript: Fully implemented in TypeScript for improved developer experience and code quality.
- Dependency Injection & Inversion of Control: Decoupled components. Programmed against interfaces with architectural boundary.
- Aliases: Path and module aliases for simpler imports.
- Testing: Jest implemented for solid state-of-the-art testing.
- Route Validation: Ensure the integrity of incoming requests with robust route validation.
- CORS: Configurable Cross-Origin Resource Sharing support for your application.
- Helmet: Enhanced security with Helmet middleware, including permitted cross-domain policies.
- Rate Limiter: Prevent abuse and ensure fair usage with a built-in rate limiting mechanism.
- Health Check Route: Easily monitor the health of your application with a dedicated health check endpoint.
- Swagger Implementation: Automatically generated API documentation available at
http://localhost:8000/docs
. - Node Cluster: Leverage the Node.js cluster module to create child processes that run simultaneously and share the same server port, enhancing the performance of your application.
- Logging: Comprehensive logging setup with Winston and daily rotating log files for better traceability and debugging.
- Nodemon: Automatically restart the server during development when file changes in the directory are detected.
- Prettier: Maintain consistent code formatting with Prettier.
- Async Error Handling: All controllers are wrapped in a
catchAsync
utility to handle errors gracefully and keep the codebase clean. - Custom Response Handler: Consistent API responses with a custom response handler that defines standard response structures for success, failure, internal errors, authentication errors, and more.
Clone the repository and install the dependencies:
git clone https://github.com/paulmuenzner/node-template.git
cd node-template
npm install
Build and start:
npm run build
npm run start
Test:
npx jest
Test coverage:
npx jest --coverage
Contributions to the Node.js template project are welcome! Whether you're interested in adding new features, fixing bugs, or improving documentation, your contributions are highly valued. To get started, fork the repository, make your changes, and submit a pull request.
See CONTRIBUTING.md for more info.
Distributed under the GNU General Public License v2.0. See LICENSE for more information.
Paul Münzner: https://paulmuenzner.com
Project Link: https://github.com/paulmuenzner/node-template