├── .eslintrc.js ├── .gitignore ├── .prettierrc ├── README.md ├── nest-cli.json ├── package-lock.json ├── package.json ├── src ├── app.module.ts ├── lib │ └── User │ │ ├── application │ │ ├── UserCreate │ │ │ └── UserCreate.ts │ │ ├── UserDelete │ │ │ └── UserDelete.ts │ │ ├── UserEdit │ │ │ └── UserEdit.ts │ │ ├── UserGetAll │ │ │ └── UserGetAll.ts │ │ └── UserGetOneById │ │ │ └── UserGetOneById.ts │ │ ├── domain │ │ ├── User.ts │ │ ├── UserCreatedAt.ts │ │ ├── UserEmail.ts │ │ ├── UserId.ts │ │ ├── UserName.ts │ │ ├── UserNotFoundError.ts │ │ └── UserRepository.ts │ │ └── infrastructure │ │ ├── InMemoryUserRepository.ts │ │ ├── NestJs │ │ ├── Validations.ts │ │ ├── user.controller.ts │ │ └── user.module.ts │ │ └── TypeOrm │ │ ├── TypeOrmUserEntity.ts │ │ └── TypeOrmUserRepository.ts └── main.ts ├── tsconfig.build.json └── tsconfig.json /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | parserOptions: { 4 | project: 'tsconfig.json', 5 | tsconfigRootDir: __dirname, 6 | sourceType: 'module', 7 | }, 8 | plugins: ['@typescript-eslint/eslint-plugin'], 9 | extends: [ 10 | 'plugin:@typescript-eslint/recommended', 11 | 'plugin:prettier/recommended', 12 | ], 13 | root: true, 14 | env: { 15 | node: true, 16 | jest: true, 17 | }, 18 | ignorePatterns: ['.eslintrc.js'], 19 | rules: { 20 | '@typescript-eslint/interface-name-prefix': 'off', 21 | '@typescript-eslint/explicit-function-return-type': 'off', 22 | '@typescript-eslint/explicit-module-boundary-types': 'off', 23 | '@typescript-eslint/no-explicit-any': 'off', 24 | }, 25 | }; 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | /build 5 | 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | pnpm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | lerna-debug.log* 14 | 15 | # OS 16 | .DS_Store 17 | 18 | # Tests 19 | /coverage 20 | /.nyc_output 21 | 22 | # IDEs and editors 23 | /.idea 24 | .project 25 | .classpath 26 | .c9/ 27 | *.launch 28 | .settings/ 29 | *.sublime-workspace 30 | 31 | # IDE - VSCode 32 | .vscode/* 33 | !.vscode/settings.json 34 | !.vscode/tasks.json 35 | !.vscode/launch.json 36 | !.vscode/extensions.json 37 | 38 | # dotenv environment variable files 39 | .env 40 | .env.development.local 41 | .env.test.local 42 | .env.production.local 43 | .env.local 44 | 45 | # temp directory 46 | .temp 47 | .tmp 48 | 49 | # Runtime data 50 | pids 51 | *.pid 52 | *.seed 53 | *.pid.lock 54 | 55 | # Diagnostic reports (https://nodejs.org/api/report.html) 56 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 57 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NestJS TypeORM Supabase Hexagonal 2 | -------------------------------------------------------------------------------- /nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/nest-cli", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src", 5 | "compilerOptions": { 6 | "deleteOutDir": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nestjs-typeorm-hex", 3 | "version": "0.0.1", 4 | "description": "", 5 | "author": "", 6 | "private": true, 7 | "license": "UNLICENSED", 8 | "scripts": { 9 | "build": "nest build", 10 | "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", 11 | "start": "nest start", 12 | "start:dev": "nest start --watch", 13 | "start:debug": "nest start --debug --watch", 14 | "start:prod": "node dist/main", 15 | "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", 16 | "test": "jest", 17 | "test:watch": "jest --watch", 18 | "test:cov": "jest --coverage", 19 | "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", 20 | "test:e2e": "jest --config ./test/jest-e2e.json" 21 | }, 22 | "dependencies": { 23 | "@nestjs/common": "^10.0.0", 24 | "@nestjs/config": "^3.2.2", 25 | "@nestjs/core": "^10.0.0", 26 | "@nestjs/platform-express": "^10.0.0", 27 | "@nestjs/typeorm": "^10.0.2", 28 | "class-transformer": "^0.5.1", 29 | "class-validator": "^0.14.1", 30 | "pg": "^8.11.5", 31 | "reflect-metadata": "^0.2.2", 32 | "rxjs": "^7.8.1", 33 | "typeorm": "^0.3.20" 34 | }, 35 | "devDependencies": { 36 | "@nestjs/cli": "^10.0.0", 37 | "@nestjs/schematics": "^10.0.0", 38 | "@nestjs/testing": "^10.0.0", 39 | "@types/express": "^4.17.17", 40 | "@types/jest": "^29.5.2", 41 | "@types/node": "^20.13.0", 42 | "@types/supertest": "^6.0.0", 43 | "@typescript-eslint/eslint-plugin": "^6.0.0", 44 | "@typescript-eslint/parser": "^6.0.0", 45 | "eslint": "^8.42.0", 46 | "eslint-config-prettier": "^9.0.0", 47 | "eslint-plugin-prettier": "^5.0.0", 48 | "jest": "^29.5.0", 49 | "prettier": "^3.0.0", 50 | "source-map-support": "^0.5.21", 51 | "supertest": "^6.3.3", 52 | "ts-jest": "^29.1.0", 53 | "ts-loader": "^9.4.3", 54 | "ts-node": "^10.9.1", 55 | "tsconfig-paths": "^4.2.0", 56 | "typescript": "^5.1.3" 57 | }, 58 | "jest": { 59 | "moduleFileExtensions": [ 60 | "js", 61 | "json", 62 | "ts" 63 | ], 64 | "rootDir": "src", 65 | "testRegex": ".*\\.spec\\.ts$", 66 | "transform": { 67 | "^.+\\.(t|j)s$": "ts-jest" 68 | }, 69 | "collectCoverageFrom": [ 70 | "**/*.(t|j)s" 71 | ], 72 | "coverageDirectory": "../coverage", 73 | "testEnvironment": "node" 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { UserModule } from './lib/User/infrastructure/NestJs/user.module'; 3 | import { TypeOrmModule } from '@nestjs/typeorm'; 4 | import { ConfigModule } from '@nestjs/config'; 5 | import { TypeOrmUserEntity } from './lib/User/infrastructure/TypeOrm/TypeOrmUserEntity'; 6 | 7 | @Module({ 8 | imports: [ 9 | ConfigModule.forRoot(), 10 | TypeOrmModule.forRoot({ 11 | type: 'postgres', 12 | url: process.env.DATABASE_URL, 13 | entities: [TypeOrmUserEntity], 14 | synchronize: process.env.NODE_ENV === 'dev', 15 | }), 16 | UserModule, 17 | ], 18 | }) 19 | export class AppModule {} 20 | -------------------------------------------------------------------------------- /src/lib/User/application/UserCreate/UserCreate.ts: -------------------------------------------------------------------------------- 1 | import { User } from '../../domain/User'; 2 | import { UserCreatedAt } from '../../domain/UserCreatedAt'; 3 | import { UserEmail } from '../../domain/UserEmail'; 4 | import { UserId } from '../../domain/UserId'; 5 | import { UserName } from '../../domain/UserName'; 6 | import { UserRepository } from '../../domain/UserRepository'; 7 | 8 | export class UserCreate { 9 | constructor(private repository: UserRepository) {} 10 | 11 | async run( 12 | id: string, 13 | name: string, 14 | email: string, 15 | createdAt: Date, 16 | ): Promise { 17 | const user = new User( 18 | new UserId(id), 19 | new UserName(name), 20 | new UserEmail(email), 21 | new UserCreatedAt(createdAt), 22 | ); 23 | 24 | return this.repository.create(user); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/lib/User/application/UserDelete/UserDelete.ts: -------------------------------------------------------------------------------- 1 | import { UserId } from '../../domain/UserId'; 2 | import { UserRepository } from '../../domain/UserRepository'; 3 | 4 | export class UserDelete { 5 | constructor(private repository: UserRepository) {} 6 | 7 | async run(id: string): Promise { 8 | await this.repository.delete(new UserId(id)); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/lib/User/application/UserEdit/UserEdit.ts: -------------------------------------------------------------------------------- 1 | import { User } from '../../domain/User'; 2 | import { UserCreatedAt } from '../../domain/UserCreatedAt'; 3 | import { UserEmail } from '../../domain/UserEmail'; 4 | import { UserId } from '../../domain/UserId'; 5 | import { UserName } from '../../domain/UserName'; 6 | import { UserRepository } from '../../domain/UserRepository'; 7 | 8 | export class UserEdit { 9 | constructor(private repository: UserRepository) {} 10 | 11 | async run( 12 | id: string, 13 | name: string, 14 | email: string, 15 | createdAt: Date, 16 | ): Promise { 17 | const user = new User( 18 | new UserId(id), 19 | new UserName(name), 20 | new UserEmail(email), 21 | new UserCreatedAt(createdAt), 22 | ); 23 | 24 | return this.repository.edit(user); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/lib/User/application/UserGetAll/UserGetAll.ts: -------------------------------------------------------------------------------- 1 | import { User } from '../../domain/User'; 2 | import { UserRepository } from '../../domain/UserRepository'; 3 | 4 | export class UserGetAll { 5 | constructor(private repository: UserRepository) {} 6 | 7 | async run(): Promise { 8 | return this.repository.getAll(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/lib/User/application/UserGetOneById/UserGetOneById.ts: -------------------------------------------------------------------------------- 1 | import { User } from '../../domain/User'; 2 | import { UserId } from '../../domain/UserId'; 3 | import { UserNotFoundError } from '../../domain/UserNotFoundError'; 4 | import { UserRepository } from '../../domain/UserRepository'; 5 | 6 | export class UserGetOneById { 7 | constructor(private repository: UserRepository) {} 8 | 9 | async run(id: string): Promise { 10 | const user = await this.repository.getOneById(new UserId(id)); 11 | 12 | if (!user) throw new UserNotFoundError('User not found'); // retorna 404 13 | 14 | return user; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/lib/User/domain/User.ts: -------------------------------------------------------------------------------- 1 | import { UserCreatedAt } from './UserCreatedAt'; 2 | import { UserEmail } from './UserEmail'; 3 | import { UserId } from './UserId'; 4 | import { UserName } from './UserName'; 5 | 6 | export class User { 7 | id: UserId; 8 | name: UserName; 9 | email: UserEmail; 10 | createdAt: UserCreatedAt; 11 | 12 | constructor( 13 | id: UserId, 14 | name: UserName, 15 | email: UserEmail, 16 | createdAt: UserCreatedAt, 17 | ) { 18 | this.id = id; 19 | this.name = name; 20 | this.email = email; 21 | this.createdAt = createdAt; 22 | } 23 | 24 | public nameAndEmail() { 25 | return `${this.name} - ${this.email}`; 26 | } 27 | 28 | public toPlainObject() { 29 | return { 30 | id: this.id.value, 31 | name: this.name.value, 32 | email: this.email.value, 33 | createdAt: this.createdAt.value, 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/lib/User/domain/UserCreatedAt.ts: -------------------------------------------------------------------------------- 1 | export class UserCreatedAt { 2 | value: Date; 3 | 4 | constructor(value: Date) { 5 | this.value = value; 6 | this.ensureIsValid(); 7 | } 8 | 9 | private ensureIsValid() { 10 | if (this.value > new Date()) { 11 | throw new Error('UserCreatedAt must be in the past'); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/lib/User/domain/UserEmail.ts: -------------------------------------------------------------------------------- 1 | export class UserEmail { 2 | value: string; 3 | 4 | constructor(value: string) { 5 | this.value = value; 6 | this.ensureIsValid(); 7 | } 8 | 9 | private ensureIsValid() { 10 | if (!this.value.includes('@') || !this.value.includes('.')) { 11 | throw new Error('UserEmail must be a valid email address'); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/lib/User/domain/UserId.ts: -------------------------------------------------------------------------------- 1 | export class UserId { 2 | value: string; 3 | 4 | constructor(value: string) { 5 | this.value = value; 6 | this.ensureIsValid(); 7 | } 8 | 9 | private ensureIsValid() { 10 | if (this.value.length < 5) { 11 | throw new Error('UserId must be at least 5 characters long'); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/lib/User/domain/UserName.ts: -------------------------------------------------------------------------------- 1 | export class UserName { 2 | value: string; 3 | 4 | constructor(value: string) { 5 | this.value = value; 6 | this.ensureIsValid(); 7 | } 8 | 9 | private ensureIsValid() { 10 | if (this.value.length < 3) { 11 | throw new Error('UserName must be at least 3 characters long'); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/lib/User/domain/UserNotFoundError.ts: -------------------------------------------------------------------------------- 1 | export class UserNotFoundError extends Error {} 2 | -------------------------------------------------------------------------------- /src/lib/User/domain/UserRepository.ts: -------------------------------------------------------------------------------- 1 | import { User } from './User'; 2 | import { UserId } from './UserId'; 3 | 4 | export interface UserRepository { 5 | create(user: User): Promise; 6 | getAll(): Promise; 7 | getOneById(id: UserId): Promise; 8 | edit(user: User): Promise; 9 | delete(id: UserId): Promise; 10 | } 11 | -------------------------------------------------------------------------------- /src/lib/User/infrastructure/InMemoryUserRepository.ts: -------------------------------------------------------------------------------- 1 | import { User } from '../domain/User'; 2 | import { UserId } from '../domain/UserId'; 3 | import { UserRepository } from '../domain/UserRepository'; 4 | 5 | export class InMemoryUserRepository implements UserRepository { 6 | private users: User[] = []; 7 | 8 | async create(user: User): Promise { 9 | this.users.push(user); 10 | } 11 | 12 | async getAll(): Promise { 13 | return this.users; 14 | } 15 | 16 | async getOneById(id: UserId): Promise { 17 | return this.users.find((user) => user.id.value === id.value) || null; 18 | } 19 | 20 | async edit(user: User): Promise { 21 | const index = this.users.findIndex((u) => u.id.value == user.id.value); 22 | this.users[index] = user; 23 | } 24 | 25 | async delete(id: UserId): Promise { 26 | this.users = this.users.filter((user) => user.id.value !== id.value); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/lib/User/infrastructure/NestJs/Validations.ts: -------------------------------------------------------------------------------- 1 | import { IsEmail, IsString, Length } from 'class-validator'; 2 | 3 | export class FindOneParams { 4 | @IsString() 5 | @Length(5, 255) 6 | id: string; 7 | } 8 | 9 | export class Create { 10 | @IsString() 11 | @Length(5, 255) 12 | id: string; 13 | 14 | @IsString() 15 | name: string; 16 | 17 | @IsEmail() 18 | email: string; 19 | } 20 | 21 | export class Edit { 22 | @IsString() 23 | name: string; 24 | 25 | @IsEmail() 26 | email: string; 27 | } 28 | -------------------------------------------------------------------------------- /src/lib/User/infrastructure/NestJs/user.controller.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Body, 3 | Controller, 4 | Delete, 5 | Get, 6 | Inject, 7 | NotFoundException, 8 | Param, 9 | Post, 10 | Put, 11 | } from '@nestjs/common'; 12 | import { UserGetAll } from '../../application/UserGetAll/UserGetAll'; 13 | import { UserGetOneById } from '../../application/UserGetOneById/UserGetOneById'; 14 | import { UserCreate } from '../../application/UserCreate/UserCreate'; 15 | import { UserEdit } from '../../application/UserEdit/UserEdit'; 16 | import { UserDelete } from '../../application/UserDelete/UserDelete'; 17 | import { Create, Edit, FindOneParams } from './Validations'; 18 | import { UserNotFoundError } from '../../domain/UserNotFoundError'; 19 | 20 | @Controller('user') 21 | export class UserController { 22 | constructor( 23 | @Inject('UserGetAll') private readonly userGetAll: UserGetAll, 24 | @Inject('UserGetOneById') private readonly userGetOneById: UserGetOneById, 25 | @Inject('UserCreate') private readonly userCreate: UserCreate, 26 | @Inject('UserEdit') private readonly userEdit: UserEdit, 27 | @Inject('UserDelete') private readonly userDelete: UserDelete, 28 | ) {} 29 | 30 | @Get() 31 | async getAll() { 32 | return (await this.userGetAll.run()).map((u) => u.toPlainObject()); 33 | } 34 | 35 | @Get(':id') 36 | async getOneById(@Param() params: FindOneParams) { 37 | try { 38 | return (await this.userGetOneById.run(params.id)).toPlainObject(); 39 | } catch (error) { 40 | if (error instanceof UserNotFoundError) { 41 | throw new NotFoundException(); 42 | } 43 | 44 | throw error; 45 | } 46 | } 47 | 48 | @Post() 49 | async create(@Body() body: Create) { 50 | return await this.userCreate.run( 51 | body.id, 52 | body.name, 53 | body.email, 54 | new Date(), 55 | ); 56 | } 57 | 58 | @Put(':id') 59 | async edit(@Param() params: FindOneParams, @Body() body: Edit) { 60 | return await this.userEdit.run( 61 | params.id, 62 | body.name, 63 | body.email, 64 | new Date(), 65 | ); 66 | } 67 | 68 | @Delete(':id') 69 | async delete(@Param() params: FindOneParams) { 70 | return await this.userDelete.run(params.id); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/lib/User/infrastructure/NestJs/user.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { UserController } from './user.controller'; 3 | import { UserGetAll } from '../../application/UserGetAll/UserGetAll'; 4 | import { TypeOrmUserRepository } from '../TypeOrm/TypeOrmUserRepository'; 5 | import { UserGetOneById } from '../../application/UserGetOneById/UserGetOneById'; 6 | import { UserCreate } from '../../application/UserCreate/UserCreate'; 7 | import { UserEdit } from '../../application/UserEdit/UserEdit'; 8 | import { UserDelete } from '../../application/UserDelete/UserDelete'; 9 | import { TypeOrmModule } from '@nestjs/typeorm'; 10 | import { TypeOrmUserEntity } from '../TypeOrm/TypeOrmUserEntity'; 11 | 12 | @Module({ 13 | imports: [TypeOrmModule.forFeature([TypeOrmUserEntity])], 14 | controllers: [UserController], 15 | providers: [ 16 | { 17 | provide: 'UserRepository', 18 | useClass: TypeOrmUserRepository, 19 | }, 20 | { 21 | provide: 'UserGetAll', 22 | useFactory: (repository: TypeOrmUserRepository) => 23 | new UserGetAll(repository), 24 | inject: ['UserRepository'], 25 | }, 26 | { 27 | provide: 'UserGetOneById', 28 | useFactory: (repository: TypeOrmUserRepository) => 29 | new UserGetOneById(repository), 30 | inject: ['UserRepository'], 31 | }, 32 | { 33 | provide: 'UserCreate', 34 | useFactory: (repository: TypeOrmUserRepository) => 35 | new UserCreate(repository), 36 | inject: ['UserRepository'], 37 | }, 38 | { 39 | provide: 'UserEdit', 40 | useFactory: (repository: TypeOrmUserRepository) => 41 | new UserEdit(repository), 42 | inject: ['UserRepository'], 43 | }, 44 | { 45 | provide: 'UserDelete', 46 | useFactory: (repository: TypeOrmUserRepository) => 47 | new UserDelete(repository), 48 | inject: ['UserRepository'], 49 | }, 50 | ], 51 | }) 52 | export class UserModule {} 53 | -------------------------------------------------------------------------------- /src/lib/User/infrastructure/TypeOrm/TypeOrmUserEntity.ts: -------------------------------------------------------------------------------- 1 | import { Column, CreateDateColumn, Entity, PrimaryColumn } from 'typeorm'; 2 | 3 | @Entity('users') 4 | export class TypeOrmUserEntity { 5 | @PrimaryColumn() 6 | id: string; 7 | 8 | @Column() 9 | name: string; 10 | 11 | @Column() 12 | email: string; 13 | 14 | @CreateDateColumn() 15 | createdAt: Date; 16 | } 17 | -------------------------------------------------------------------------------- /src/lib/User/infrastructure/TypeOrm/TypeOrmUserRepository.ts: -------------------------------------------------------------------------------- 1 | import { Repository } from 'typeorm'; 2 | import { UserRepository } from '../../domain/UserRepository'; 3 | import { InjectRepository } from '@nestjs/typeorm'; 4 | import { User } from '../../domain/User'; 5 | import { UserId } from '../../domain/UserId'; 6 | import { TypeOrmUserEntity } from './TypeOrmUserEntity'; 7 | import { UserName } from '../../domain/UserName'; 8 | import { UserEmail } from '../../domain/UserEmail'; 9 | import { UserCreatedAt } from '../../domain/UserCreatedAt'; 10 | 11 | export class TypeOrmUserRepository implements UserRepository { 12 | constructor( 13 | @InjectRepository(TypeOrmUserEntity) 14 | private readonly repository: Repository, 15 | ) {} 16 | 17 | private mapToDomain(u: TypeOrmUserEntity) { 18 | return new User( 19 | new UserId(u.id), 20 | new UserName(u.name), 21 | new UserEmail(u.email), 22 | new UserCreatedAt(u.createdAt), 23 | ); 24 | } 25 | 26 | async getAll(): Promise { 27 | const users = await this.repository.find(); 28 | 29 | return users.map((u) => this.mapToDomain(u)); 30 | } 31 | 32 | async getOneById(id: UserId): Promise { 33 | const user = await this.repository.findOne({ 34 | where: { 35 | id: id.value, 36 | }, 37 | }); 38 | 39 | if (!user) return null; 40 | 41 | return this.mapToDomain(user); 42 | } 43 | 44 | async create(user: User): Promise { 45 | await this.repository.save({ 46 | id: user.id.value, 47 | name: user.name.value, 48 | email: user.email.value, 49 | createdAt: user.createdAt.value, 50 | }); 51 | } 52 | 53 | async edit(user: User): Promise { 54 | await this.repository.update(user.id.value, { 55 | name: user.name.value, 56 | email: user.email.value, 57 | createdAt: user.createdAt.value, 58 | }); 59 | } 60 | 61 | async delete(id: UserId): Promise { 62 | await this.repository.delete(id.value); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | import 'reflect-metadata'; 4 | import { ValidationPipe } from '@nestjs/common'; 5 | 6 | async function bootstrap() { 7 | const app = await NestFactory.create(AppModule); 8 | app.useGlobalPipes(new ValidationPipe()); 9 | await app.listen(3000); 10 | } 11 | bootstrap(); 12 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "ES2021", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./", 13 | "incremental": true, 14 | "skipLibCheck": true, 15 | "strictNullChecks": false, 16 | "noImplicitAny": false, 17 | "strictBindCallApply": false, 18 | "forceConsistentCasingInFileNames": false, 19 | "noFallthroughCasesInSwitch": false 20 | } 21 | } 22 | --------------------------------------------------------------------------------