Skip to content

This repository provides a comprehensive Node.js template designed for building robust and scalable web applications.

License

Notifications You must be signed in to change notification settings

paulmuenzner/node-template

Repository files navigation

Issues GNU License GitHub code size in bytes GitHub top language paulmuenzner github Contributors


Node.js Template

Clustering - Logging - Testing - Error/Response Handler
EXPLORE DOCS

Plenty of features · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Usage
  3. Contributing
  4. License
  5. Contact

About The Project

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.

Features

  • 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.

(back to top)

Usage

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

(back to top)

Contributing

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.

(back to top)

License

Distributed under the GNU General Public License v2.0. See LICENSE for more information.

(back to top)

Contact

Paul Münzner: https://paulmuenzner.com

Project Link: https://github.com/paulmuenzner/node-template

(back to top)

About

This repository provides a comprehensive Node.js template designed for building robust and scalable web applications.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published