Skip to content

Commit

Permalink
feature(restful) update routes
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelyali committed Dec 14, 2018
1 parent b42c5ee commit 5dd8e41
Show file tree
Hide file tree
Showing 43 changed files with 667 additions and 230 deletions.
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
- [Repository Service](#repository-service)
- [Restful Options](#restful-options)
- [Crud Controller](#crud-controller)
- [Request Validation](#request-validation)
- [IntelliSense](#intellisense)
- [Method Override](#method-override)
- [Restful Options merge](#restfuloptions-merge)
Expand All @@ -55,7 +54,7 @@
## Install

```bash
npm i @nestjsx/crud @nestjs/typeorm typeorm class-transformer --save
npm i @nestjsx/crud @nestjs/typeorm typeorm class-validator class-transformer --save
```

## Getting Started
Expand Down Expand Up @@ -526,11 +525,33 @@ export class HeroesController implements CrudController<HeroesService, Hero> {
List of composed base methods:

```typescript
getManyBase(@Param() params: ObjectLiteral, @Query() query: RestfulParamsDto): Promise<T[]>;
getOneBase(@Param() params: ObjectLiteral, @Query() query: RestfulParamsDto): Promise<T>;
createOneBase(@Param() params: ObjectLiteral, @Body() dto: T): Promise<T>;
createManyBase(@Param() params: ObjectLiteral, @Body() dto: EntitiesBulk<T>): Promise<T[]>;
updateOneBase(@Param() params: ObjectLiteral, @Body() dto: T): Promise<T>;
getManyBase(
@Param() params: ObjectLiteral,
@Query() query: RestfulParamsDto,
): Promise<T[]>;

getOneBase(
@Param('id') id: number,
@Param() params: ObjectLiteral,
@Query() query: RestfulParamsDto,
): Promise<T>;

createOneBase(
@Param() params: ObjectLiteral,
@Body() dto: T,
): Promise<T>;

createManyBase(
@Param() params: ObjectLiteral,
@Body() dto: EntitiesBulk<T>,
): Promise<T[]>;

updateOneBase(
@Param('id') id: number,
@Param() params: ObjectLiteral,
@Body() dto: T,
): Promise<T>;

deleteOneBase(@Param() params: ObjectLiteral): Promise<void>;
```

Expand Down Expand Up @@ -563,6 +584,7 @@ export class HeroesController implements CrudController<HeroesService, Hero> {
getOneAndDoStuff() {
// do some stuff
}

}
```

Expand Down
2 changes: 2 additions & 0 deletions dist/classes/restful-service.class.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export declare abstract class RestfulService<T> {
constructor();
abstract getMany(...args: any[]): Promise<T[]>;
abstract getOne(...args: any[]): Promise<T>;
abstract createOne(...args: any[]): Promise<T>;
abstract createMany(...args: any[]): Promise<T[]>;
throwBadRequestException(msg?: any): BadRequestException;
throwNotFoundException(name?: string): NotFoundException;
}
2 changes: 1 addition & 1 deletion dist/classes/restful-service.class.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions dist/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
export declare const FEAUTURE_NAME_METADATA = "NESTJSX_FEAUTURE_NAME_METADATA";
export declare const ACTION_NAME_METADATA = "NESTJSX_ACTION_NAME_METADATA";
export declare const BASE_PATH_METADATA = "NESTJSX_BASE_PATH_METADATA";
export declare const BASE_METHOD_METADATA = "NESTJSX_BASE_METHOD_METADATA";
export declare const OVERRIDE_METHOD_METADATA = "NESTJSX_OVERRIDE_METHOD_METADATA";
export declare const CREATE_UPDATE: {
groups: string[];
};
export declare const CREATE: {
groups: string[];
};
export declare const UPDATE: {
groups: string[];
};
8 changes: 6 additions & 2 deletions dist/constants.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/constants.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion dist/decorators/crud.decorator.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
export declare const Crud: (dto?: any) => (target: object) => void;
import { ValidationPipeOptions } from '@nestjs/common';
interface CrudOptions {
validation?: ValidationPipeOptions;
}
export declare const Crud: (dto: any, crudOptions?: CrudOptions) => (target: object) => void;
export declare const Override: (name?: "getManyBase" | "getOneBase" | "createOneBase" | "updateOneBase" | "deleteOneBase") => (target: any, key: any, descriptor: PropertyDescriptor) => PropertyDescriptor;
export {};
108 changes: 62 additions & 46 deletions dist/decorators/crud.decorator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5dd8e41

Please sign in to comment.