Skip to content

Latest commit

 

History

History
143 lines (111 loc) · 4.27 KB

README.md

File metadata and controls

143 lines (111 loc) · 4.27 KB
# TypeScript Express Starter

A starter template for building a RESTful API using TypeScript, Express, TypeORM, and BullMQ for background processing. This project includes user authentication, caching, and background tasks like sending emails.

## Features

-   **TypeScript** for static type checking.
-   **Express** as the web framework.
-   **TypeORM** for database interaction.
-   **BullMQ** for background job processing.
-   **Redis** for caching and queue management.
-   **Dependency Injection** with inversify.
-   **Decorator-based** routing and caching.

## Getting Started

### Prerequisites

-   Node.js
-   Redis server
-   PostgreSQL (or any other database supported by TypeORM)

### Installation

1. Clone the repository and install dependencies:
    ```sh
    git clone https://github.com/MahmudulHassan5809/typescript-express-starter.git
    cd typescript-express-starter
    npm install
    ```
  1. Set up environment variables in a .env file.

  2. Run the application:

    npm run start
        http://localhost:8080
        http://localhost:8080/api-docs
        http://localhost:8080/task-monitor

Project Structure

typescript-express-starter
├── eslint.config.mjs
├── nodemon.json
├── package.json
├── package-lock.json
├── README.md
├── src
│   ├── core
│   │   ├── cache
│   │   ├── config
│   │   ├── db
│   │   ├── di
│   │   ├── enum
│   │   ├── errors
│   │   ├── helpers
│   │   ├── interfaces
│   │   ├── logger
│   │   ├── middlewares
│   │   ├── repositories
│   │   ├── swagger
│   │   └── @types
│   ├── index.ts
│   ├── migrations
│   ├── modules
│   │   ├── auth
│   │   └── users
│   ├── routers.ts
│   ├── seeders
│   └── workers
│       ├── connection.ts
│       ├── index.ts
│       └── processors
├── tsconfig.json

Folder Descriptions

  • src/core: Core modules and utilities for the project.

    • cache: Cache management modules.
    • config: Configuration files and environment setup.
    • db: Database connection setup.
    • di: Dependency injection setup.
    • enum: Enumerations used in the project.
    • errors: Custom error handling and exceptions.
    • helpers: Helper functions and utilities.
    • interfaces: TypeScript interfaces.
    • logger: Logging configuration and setup.
    • middlewares: Express middlewares.
    • repositories: Base repository classes.
    • swagger: Swagger documentation setup.
    • @types: Custom TypeScript type definitions.
  • src/migrations: Database migration files.

  • src/modules: Feature modules of the application.

    • auth: Authentication module containing controllers, DTOs, interfaces, routes, and services.
    • users: User management module containing controllers, DTOs, interfaces, models, repositories, routes, and services.
  • src/seeders: Database seeder files.

  • src/workers: Background job processors.

    • connection.ts: Redis connection setup for workers.
    • index.ts: Worker initialization.
    • processors: Individual job processors (e.g., sending emails).

Usage

  • To start the development server: npm run dev
  • To build the project: npm run build
  • To run the production server: npm start
  • To generate migrations: npm run migration:generate src/migrations/{migrationName}
  • To run migrations: npm run migration:run

Usage Docker

  • To start the development server: docker compose up --build
  • To generate migrations: docker compose run --rm app npm run typeorm:generate src/migrations/{migrationName}
  • To run migrations: docker compose run --rm app npm run migration:run

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.


This README should provide a comprehensive overview of your project, including its structure and features.