Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
160 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './note.entity'; | ||
export * from './notes.service'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm'; | ||
|
||
@Entity('notes') | ||
export class Note { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column({ name: 'revision_id', nullable: false }) | ||
revisionId: number; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Controller } from '@nestjs/common'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
import { Crud } from '@nestjsx/crud'; | ||
|
||
import { Note } from './note.entity'; | ||
import { NotesService } from './notes.service'; | ||
import { dto } from './requests'; | ||
import { serialize } from './responses'; | ||
|
||
@Crud({ | ||
model: { type: Note }, | ||
dto, | ||
serialize, | ||
query: { | ||
alwaysPaginate: true, | ||
}, | ||
}) | ||
@ApiTags('notes') | ||
@Controller('/notes') | ||
export class NotesController { | ||
constructor(public service: NotesService) {} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
|
||
import { Note } from './note.entity'; | ||
import { NotesService } from './notes.service'; | ||
import { NotesController } from './notes.controller'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([Note])], | ||
providers: [NotesService], | ||
exports: [NotesService], | ||
controllers: [NotesController], | ||
}) | ||
export class NotesModule {} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { TypeOrmCrudService } from '../../../packages/crud-typeorm/src'; | ||
|
||
import { Note } from './note.entity'; | ||
|
||
@Injectable() | ||
export class NotesService extends TypeOrmCrudService<Note> { | ||
constructor(@InjectRepository(Note) repo) { | ||
super(repo); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsNumber } from 'class-validator'; | ||
|
||
export class CreateNoteDto { | ||
@ApiProperty({ type: 'number' }) | ||
@IsNumber() | ||
revisionId: string; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { CreateNoteDto } from './create-note.dto'; | ||
|
||
export const dto = { | ||
create: CreateNoteDto, | ||
}; |
12 changes: 12 additions & 0 deletions
12
integration/crud-typeorm/notes/responses/get-note-response.dto.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsNumber } from 'class-validator'; | ||
|
||
export class GetNoteResponseDto { | ||
@ApiProperty({ type: 'number' }) | ||
@IsNumber() | ||
id: string; | ||
|
||
@ApiProperty({ type: 'number' }) | ||
@IsNumber() | ||
revisionId: string; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { GetNoteResponseDto } from './get-note-response.dto'; | ||
|
||
export const serialize = { | ||
get: GetNoteResponseDto, | ||
}; |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
|
||
import { TypeOrmCrudService } from '../../../crud-typeorm/src/typeorm-crud.service'; | ||
import { Note } from '../../../../integration/crud-typeorm/notes'; | ||
|
||
@Injectable() | ||
export class NotesService extends TypeOrmCrudService<Note> { | ||
constructor(@InjectRepository(Note) repo) { | ||
super(repo); | ||
} | ||
} |
This file contains 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