This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Task { | |
| @ApiProperty() | |
| id: string; | |
| @ApiProperty() | |
| title: string; | |
| @ApiProperty() | |
| description: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ApiOkResponse({ | |
| description: 'Retrieved task by ID successfully', | |
| type: Task | |
| }) | |
| @ApiNotFoundResponse({ description: 'No task found for ID' }) | |
| @ApiInternalServerErrorResponse({ | |
| description: 'Internal server error', | |
| }) | |
| @Get(':id') | |
| getTask(@Param('id') taskId: string): Task { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ApiTags('task') | |
| @Controller('task') | |
| export class TaskController {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function bootstrap() { | |
| const app = await NestFactory.create(AppModule); | |
| const APP_NAME = process.env.npm_package_name; | |
| const APP_VERSION = process.env.npm_package_version; | |
| const options = new DocumentBuilder() | |
| .setTitle(APP_NAME) | |
| .setDescription(`The ${APP_NAME} API description`) | |
| .setVersion(APP_VERSION) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Task { | |
| id: string; | |
| title: string; | |
| description: string; | |
| dateTimeCreated: string; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class CreateTask { | |
| @IsNotEmpty() | |
| @IsString() | |
| title: string; | |
| @IsNotEmpty() | |
| @IsString() | |
| description: string; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Injectable() | |
| export class TaskService { | |
| private tasks: Task[] = []; | |
| createTask(createTask: CreateTask): Task { | |
| const { title, description } = createTask; | |
| const newTask: Task = { | |
| id: uuidv4(), | |
| title, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Controller('task') | |
| export class TaskController { | |
| constructor(private readonly taskService: TaskService) { } | |
| @Get() | |
| getTasks(): Task[] { | |
| return this.taskService.getTasks(); | |
| } | |
| @Get(':id') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const rawSQLQuery = async () => { | |
| const companyRepository = getRepository(Company); | |
| return companyRepository.query('SELECT * FROM "company"'); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const rawSQLQuery = (prisma: PrismaClient) => { | |
| return prisma.queryRaw('SELECT * FROM "Company";'); | |
| }; |