Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/muneebhashone/typescript-backend-toolkit

TypeScript Backend Toolkit - Express.js - Swagger (OpenAPI 3.0) Autogenered docs, Zod - BullMQ - React Email - Mailgun - Docker - MongoDB (Mongoose) - Socket.io
https://github.com/muneebhashone/typescript-backend-toolkit

boilerplate bullmq express javascript mailgun mongoose node openapi openapi-generator openapi-specification postgresql prisma react react-email socket-io swagger template toolkit typescript zod

Last synced: about 22 hours ago
JSON representation

TypeScript Backend Toolkit - Express.js - Swagger (OpenAPI 3.0) Autogenered docs, Zod - BullMQ - React Email - Mailgun - Docker - MongoDB (Mongoose) - Socket.io

Awesome Lists containing this project

README

        


Zod logo

✨ TypeScript Backend Toolkit ✨





Robust backend boilerplate designed for scalability, flexibility, and ease of development. It's packed with modern technologies and best practices to kickstart your next backend project.


## Prerequisites

Before you get started, make sure you have the following installed on your machine:

- **Docker + Docker Compose**
- **PNPM**
- **Node.js 20+ (LTS)**

## How to Run

1. **Set up Docker Services**:

- Run the following command to start MongoDB and Redis instances locally:
```sh
docker compose up -d
```
2. **Install Dependencies**:

- Use pnpm to install all the necessary dependencies:
```sh
pnpm i
```
3. **Configure Environment Variables**:

- Create a `.env` file in the root directory.
- Use the provided `.env.sample` as a template to enter all the required environment variables.

## What's Included

- **OpenAPI Autogenerated Swagger Docs** : Automatically generated Swagger docs through MagicRouter API and Zod, accessible at `/api-docs`.
- **Auth Module**: Includes Google Sign-In support for easy authentication.
- **User Management**: Comprehensive user management functionality.
- **File Upload**: Handles file uploads with Multer and Amazon S3.
- **Data Validation & Serialization**: Zod is used for validation and serialization of data.
- **Configuration Management**: Managed using dotenv-cli and validated with Zod for accuracy and safety.
- **Middlewares**:
- **Authorization**: Built-in authorization middleware.
- **Zod Schema Validation**: Ensures your API inputs are correctly validated.
- **JWT Extraction**: Easily extract and verify JWT tokens.
- **Type-safe Email Handling**: Emails are managed using React Email and Mailgun for dynamic and flexible email handling.
- **Queues**: Powered by BullMQ with Redis for handling background jobs.
- **ESLint Setup**: Pre-configured ESLint setup for consistent code quality.
```sh
pnpm run lint
```
- **Development Server**: Run the server in development mode using ts-node-dev:
```sh
pnpm run dev
```
- **Build Process**: Efficiently bundle your project using tsup:
```sh
pnpm run build
```
- **PM2 Support**: Out-of-the-box support for PM2 to manage your production processes.

## Folder Structure
```plaintext
├── build.ts
├── docker-compose.yml
├── docs
│   └── EMAIL.md
├── ecosystem.config.js
├── eslint.config.mjs
├── firebase-adminsdk-creds.json
├── LICENSE
├── logo.webp
├── modules.d.ts
├── package.json
├── pnpm-lock.yaml
├── public
│   ├── index.html
│   ├── logo.webp
│   ├── script.js
│   └── styles.css
├── README.md
├── src
│   ├── common
│   │   ├── common.schema.ts
│   │   └── common.utils.ts
│   ├── config
│   │   └── config.service.ts
│   ├── email
│   │   ├── email.service.ts
│   │   └── templates
│   │   └── ResetPassword.tsx
│   ├── enums.ts
│   ├── healthcheck
│   │   ├── healthcheck.controller.ts
│   │   └── healthcheck.routes.ts
│   ├── lib
│   │   ├── aws.service.ts
│   │   ├── common.schema.ts
│   │   ├── database.ts
│   │   ├── email.server.ts
│   │   ├── firebase-admin.service.ts
│   │   ├── logger.service.ts
│   │   ├── mailgun.server.ts
│   │   ├── queue.server.ts
│   │   ├── realtime.server.ts
│   │   ├── redis.server.ts
│   │   └── session.store.ts
│   ├── main.ts
│   ├── middlewares
│   │   ├── can-access.middleware.ts
│   │   ├── extract-jwt-schema.middleware.ts
│   │   ├── multer-s3.middleware.ts
│   │   └── validate-zod-schema.middleware.ts
│   ├── modules
│   │   ├── auth
│   │   │   ├── auth.constants.ts
│   │   │   ├── auth.controller.ts
│   │   │   ├── auth.router.ts
│   │   │   ├── auth.schema.ts
│   │   │   └── auth.service.ts
│   │   └── user
│   │   ├── user.controller.ts
│   │   ├── user.dto.ts
│   │   ├── user.model.ts
│   │   ├── user.router.ts
│   │   ├── user.schema.ts
│   │   └── user.services.ts
│   ├── openapi
│   │   ├── magic-router.ts
│   │   ├── openapi.utils.ts
│   │   ├── swagger-doc-generator.ts
│   │   ├── swagger-instance.ts
│   │   └── zod-extend.ts
│   ├── queues
│   │   └── email.queue.ts
│   ├── routes
│   │   └── routes.ts
│   ├── types.ts
│   ├── upload
│   │   ├── upload.controller.ts
│   │   └── upload.router.ts
│   └── utils
│   ├── api.utils.ts
│   ├── auth.utils.ts
│   ├── common.utils.ts
│   ├── email.utils.ts
│   ├── getPaginator.ts
│   ├── globalErrorHandler.ts
│   ├── isUsername.ts
│   └── responseInterceptor.ts
└── tsconfig.json
```

## Roadmap

- **Socket.io Support:** Adding support for Redis adapter and a chat module.
- **Notification Infrastructure**: Notifications via FCM and Novu.
- **Ansible Playbook** : Create an Ansible playbook for server configuration to set up a basic environment quickly and consistently.
- **AWS CDK Support** : Integrate AWS CDK for infrastructure management, making it easier to deploy and manage cloud resources.
- **Monorepo Support** : Implement monorepo architecture using Turborepo and Pnpm for better project organization and scalability.
- **AWS Lambda Support** : Add support for deploying serverless functions on AWS Lambda.
- **Cloudflare Workers Support** : Enable Cloudflare Workers support for edge computing and faster request handling.
- **Postgres Support with Drizzle** : Add support for PostgreSQL using Drizzle ORM for better relational database management.
- **Containerization with Docker** : Implement containerization to ensure the project can be easily deployed to any environment using Docker.
- **Kubernetes Support** : Integrate Kubernetes for container orchestration, enabling scalable and automated deployment of the application.
- **CI/CD with GitHub Actions** : Implement a CI/CD pipeline using GitHub Actions to automate testing, building, and deployment processes.
- **Testing with Jest**: Add support for unit and integration testing using Jest to ensure code reliability and maintainability.

## Contributions

Feel free to contribute to this project by submitting issues or pull requests. Let's build something amazing together!

## **License**

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.