Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/doannc2212/nestjs-starter


https://github.com/doannc2212/nestjs-starter

bun clean-architecture cqrs cqrs-architectural-pattern docker domain-driven-design graphql grpc javascript nestjs schema-first typeorm typescript

Last synced: 3 days ago
JSON representation

Awesome Lists containing this project

README

        

I was unable to retrieve the current `README.md` file. Let's start with creating a new one. Here is a draft:

---

# NestJS Starter

## Overview

This repository is a starter template for NestJS applications. It includes several essential features and configurations to help you get started quickly.

## Features

- **TypeORM Migration**: Seamlessly manage database migrations using TypeORM.
- **CLEAN Architecture**: Implement a clean architecture to maintain scalable and maintainable code.
- **gRPC**: Integrate gRPC for efficient communication between microservices.
- **GraphQL**: Use GraphQL to build flexible and efficient APIs.
- **Example API**: Includes examples for pagination, create, update, delete, and read operations.
- **Error Handling and Interceptors**: Centralized error handling and custom interceptors for enhanced functionality.

## Getting Started

### Prerequisites

- Node.js
- Bun
- Docker (optional for running databases)

### Installation

1. Clone the repository:

```bash
git clone https://github.com/doannc2212/nestjs-starter.git
cd nestjs-starter
```

2. Install dependencies:

```bash
bun install
```

3. Configure environment variables by copying `.dev.env` to `.env` and updating the values as needed.

### Running the Application

To start the application, use the following command:

```bash
bun start:dev
```

### Database Migration

To run database migrations, use the following command:

```bash
bun migration:run
```

To create database migrations, use the following command:

```bash
NAME= bun migration:create
```

### Using gRPC

To use gRPC, configure your services and proto files, and start the gRPC server:

### Using GraphQL

To use GraphQL, navigate to `/graphql` endpoint in your browser to access the GraphQL playground.

## Example API

### Pagination

Example code for pagination:

```typescript
@Get()
async findAll(@Query() query: PaginationQueryDto) {
return this.service.findAll(query);
}
```

### Create, Update, Delete, Read Operations

Example code for creating a record:

```typescript
@Post()
async create(@Body() createDto: CreateDto) {
return this.service.create(createDto);
}
```

## Error Handling and Interceptors

Centralized error handling and custom interceptors are configured to manage responses and errors efficiently.

## Todo

- [x] Infrastrucutre
- [x] Aggregate
- [x] Repository
- [x] Presentation (graphql and grpc)
- [x] Service communication
- [ ] Observability
- [x] Linter config (commitlint and eslint)
- [x] Formatter
- [x] First api example
- [ ] Implement transaction chaning. Be aware that asynclocalstorage is currently not work with bun in some case
https://github.com/oven-sh/bun/issues/6393
- [ ] take an eye on this: https://github.com/SocketSomeone/nestjs-resilience

## License

This project is licensed under the MIT License.

---

Feel free to update or add any specific details as needed.

---