# nest-learn **Repository Path**: jxmlearner/nest-learn ## Basic Information - **Project Name**: nest-learn - **Description**: No description available - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-01-19 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Nest.js 学习参考:https://www.youtube.com/playlist?list=PLPF-H6Hf8xrrzXQvg3jMgotCEZ_TBlOfA https://blog.csdn.net/weixin_43902189 ## 模块定义示例 ```js @Module({ providers: [ForumService], controllers: [ForumController], imports: [ PostModule, CommentModule, AuthModule ], exports: [ ForumService ] }) export class ForumModule {} ``` ## 提供器 ```js import { TasksController } from './tasks.controller'; import { TasksService } from './tasks.service'; import { LoggerService } from '../shared/logger.service'; @Module({ controllers: [ TasksController ], providers: [ TasksService, LoggerService ] }) export class TasksModule ``` ## Post示例代码 ```js @Post() async createTask( @Body('title') title: string, @Body('description') description: string ): Promise { return this.tasksService.createTask(title, description); } // service async createTask(title: string, description: string) { const task: Task = { id: uuid(), title, description, status: TaskStatus.OPEN, }; this.tasks.push(task); return task; } ``` ## nest pipe 1. `cnpm i class-validator class-transformer -S` ## nest typeorm 1. `cnpm i @nestjs/typeorm typeorm pg -S` ## repository 1. `yarn remove uuid` ## auth 模块 1. `nest g module auth` 2. `nest g controller auth --no-spec` 2. `nest g service auth --no-spec`