Express Typescript
Theme by
Geekyants |Updated:
3 Apr 2023
|1231 Stars
Express + TypeScript + Boilerplate for Web / API App
Categories
Overview
This product is a boilerplate for a Node.js app built using the Express.js web framework. It utilizes TypeScript for writing the app’s logic and takes advantage of Node’s Cluster API to handle load on multi-core systems. The boilerplate includes various packages for different functionalities such as storing custom constant configurations, database management using MongoDB, caching, routing, authentication, logging, exception handling, views with PUG template engine, and background queues with Kue.
Features
- Express.js Web Framework: Built using Express.js, a popular web framework for Node.js.
- TypeScript Support: Written in TypeScript, allowing for enhanced code organization and error checking.
- Multi-Core Support: Utilizes Node’s Cluster API to take advantage of multi-core systems and handle load efficiently.
- Environment Configuration: Uses DotEnv package to store custom constant configurations within the process.env.
- Database Management: Includes Mongoose, a MongoDB object modeling package for Node.js, for seamless database interactions.
- Caching: Utilizes memory-cache, a simple in-memory cache for Node.js.
- Routing: Includes express-router for handling routing and has distributed routes into two files: Web Routes and API Routes.
- Route Authentication Middleware: Configures Web routes with CSRF Token and API routes with JSON Web Token for secure authentication.
- Authentication Strategies: Utilizes Passport.js, a compatible authentication middleware for Node.js, for implementing authentication strategies.
- Logging: Includes a custom Log class built in middlewares folder for logging and manages log files by date, removing them after a specified number of days.
- Exception Handling: Includes two classes, Handler and NativeEvent, for handling and logging exceptions.
- View Rendering: Uses the PUG template engine for rendering views.
- Background Queues: Includes the use of Kue for handling background queues.
Installation
To install and run this boilerplate, follow these steps:
Make sure you have the following prerequisites installed:
- Node.js (>= 10.5.0)
- tsc (>= 3.0.1)
- TypeScript (>= 3.0.1)
- Mongoose (>= 3.6.2)
- Redis
Clone the repository or download the source code.
Configure the necessary files and folders as required.
Run the app using the provided commands.
Summary
In summary, this Node.js app boilerplate built with Express.js and TypeScript offers a comprehensive set of features for developing a robust application. It includes support for multi-core systems, environment configuration, database management, caching, routing, authentication with various strategies, logging, exception handling, view rendering, and background queues. By providing a solid foundation with these features, developers can focus on building their specific application logic on top of this boilerplate.