diff --git a/libs/prisma/src/processes/create.process.ts b/libs/prisma/src/processes/create.process.ts index d00a241..1517727 100644 --- a/libs/prisma/src/processes/create.process.ts +++ b/libs/prisma/src/processes/create.process.ts @@ -16,7 +16,7 @@ export class PrismaCreateProcess this.dataResult = await this.getDelegate().create(this.dataInsert); } - result() { + output() { this.dataResult; } } diff --git a/libs/prisma/src/processes/delete.process.ts b/libs/prisma/src/processes/delete.process.ts index 27ca45d..38a4647 100644 --- a/libs/prisma/src/processes/delete.process.ts +++ b/libs/prisma/src/processes/delete.process.ts @@ -14,7 +14,7 @@ export class PrismaDeleteProcess }); } - result() { + output() { return this.dataResult; } } diff --git a/libs/prisma/src/processes/list.process.ts b/libs/prisma/src/processes/list.process.ts index 0c4b5be..e42928d 100644 --- a/libs/prisma/src/processes/list.process.ts +++ b/libs/prisma/src/processes/list.process.ts @@ -8,7 +8,7 @@ export class PrismaListProcess extends PrismaProcess implements ListProcess { this.data = await this.getDelegate().findMany(); } - result() { + output() { return this.data; } } diff --git a/libs/prisma/src/processes/read.process.ts b/libs/prisma/src/processes/read.process.ts index 4b3e2c1..ac6250d 100644 --- a/libs/prisma/src/processes/read.process.ts +++ b/libs/prisma/src/processes/read.process.ts @@ -11,7 +11,7 @@ export class PrismaReadProcess extends PrismaProcess implements CreateProcess { }); } - result() { + output() { return this.data; } } diff --git a/libs/prisma/src/processes/update.process.ts b/libs/prisma/src/processes/update.process.ts index 6b251bd..539a018 100644 --- a/libs/prisma/src/processes/update.process.ts +++ b/libs/prisma/src/processes/update.process.ts @@ -16,7 +16,7 @@ export class PrismaUpdateProcess }); } - result() { + output() { return this.dataResult; } } diff --git a/libs/skeleton/src/executors/default.executor.ts b/libs/skeleton/src/executors/default.executor.ts index 450cf52..d5f5571 100644 --- a/libs/skeleton/src/executors/default.executor.ts +++ b/libs/skeleton/src/executors/default.executor.ts @@ -12,13 +12,13 @@ export class DefaultExecutor { await this.process.after(); } - getResult(): any { - return this.process.result(); + getOutput(): any { + return this.process.output(); } static async bootstrap(process: ISkeletonProcess): Promise { const executor = new DefaultExecutor(process); await executor.execute(); - return executor.getResult(); + return executor.getOutput(); } } diff --git a/libs/skeleton/src/interfaces/controller/skeleton-crud.controller.interface.ts b/libs/skeleton/src/interfaces/controller/skeleton-crud.controller.interface.ts index 194e06b..06795d5 100644 --- a/libs/skeleton/src/interfaces/controller/skeleton-crud.controller.interface.ts +++ b/libs/skeleton/src/interfaces/controller/skeleton-crud.controller.interface.ts @@ -1,8 +1,8 @@ export interface ISkeletonCRUDController { - create(); - delete(); + create(body); + delete(id); list(); - pagination(); + pagination(params: { page?: number; limit?: number }); read(id); - update(); + update(id, body); } diff --git a/libs/skeleton/src/interfaces/skeleton-process.interface.ts b/libs/skeleton/src/interfaces/skeleton-process.interface.ts index 314ced7..e6c12f2 100644 --- a/libs/skeleton/src/interfaces/skeleton-process.interface.ts +++ b/libs/skeleton/src/interfaces/skeleton-process.interface.ts @@ -6,5 +6,5 @@ export interface ISkeletonProcess { end(); after(); - result(); + output(); } diff --git a/libs/skeleton/src/processes/default.process.ts b/libs/skeleton/src/processes/default.process.ts index b66b379..efa8b18 100644 --- a/libs/skeleton/src/processes/default.process.ts +++ b/libs/skeleton/src/processes/default.process.ts @@ -8,7 +8,7 @@ export class DefaultProcess implements ISkeletonProcess { async end(): Promise {} async after(): Promise {} - result(): any { - return 'Hello World'; + output(): any { + return 'Not Implemented Yet!'; } } diff --git a/libs/skeleton/src/skeleton-crud.controller.ts b/libs/skeleton/src/skeleton-crud.controller.ts index 0355164..5a7d8f2 100644 --- a/libs/skeleton/src/skeleton-crud.controller.ts +++ b/libs/skeleton/src/skeleton-crud.controller.ts @@ -1,4 +1,13 @@ -import { Delete, Get, Inject, Param, Patch, Post } from '@nestjs/common'; +import { + Body, + Delete, + Get, + Inject, + Param, + Patch, + Post, + Query, +} from '@nestjs/common'; import { CREATE_PROCESS, DELETE_PROCESS, @@ -27,12 +36,12 @@ export class SkeletonCRUDController implements ISkeletonCRUDController { ) {} @Post() - async create(): Promise { + async create(@Body() body): Promise { return await DefaultExecutor.bootstrap(this.createProcess); } @Delete(':id') - async delete() { + async delete(@Param('id') id) { return await DefaultExecutor.bootstrap(this.deleteProcess); } @@ -42,7 +51,9 @@ export class SkeletonCRUDController implements ISkeletonCRUDController { } @Get() - async pagination() { + async pagination( + @Query() params: { page?: number; limit?: number } = { page: 1, limit: 10 }, + ) { return await DefaultExecutor.bootstrap(this.paginationProcess); } @@ -52,7 +63,7 @@ export class SkeletonCRUDController implements ISkeletonCRUDController { } @Patch() - async update() { + async update(@Param('id') id, @Body() body) { return await DefaultExecutor.bootstrap(this.updateProcess); } } diff --git a/package.json b/package.json index 6611255..989a3f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aditama-labs/nest-autocrud", - "version": "0.0.22", + "version": "0.0.23", "description": "NestJS Auto CRUD Library", "author": "Supan Adit Pratama", "license": "MIT", diff --git a/scripts/unix/release.sh b/scripts/unix/release.sh old mode 100644 new mode 100755 diff --git a/src/app.controller.ts b/src/app.controller.ts index a9bafcf..df32091 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -1,5 +1,5 @@ import { SkeletonCRUDController } from '@aditama-labs/nest-autocrud/skeleton'; import { Controller } from '@nestjs/common'; -@Controller('hello') +@Controller('example') export class AppController extends SkeletonCRUDController {} diff --git a/src/app.module.ts b/src/app.module.ts index 873bd60..fd14c7b 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -2,11 +2,12 @@ import { PrismaModule } from '@aditama-labs/nest-autocrud/prisma'; import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; +import { PrismaClient } from '@prisma/client'; @Module({ imports: [ PrismaModule.forRoot({ - delegate: (prisma) => prisma.user, + delegate: (prisma: PrismaClient) => prisma.user, }), ], controllers: [AppController], diff --git a/src/processes/list.process.ts b/src/processes/list.process.ts index 06bd0eb..739eced 100644 --- a/src/processes/list.process.ts +++ b/src/processes/list.process.ts @@ -6,7 +6,7 @@ export class AppListProcess extends PrismaListProcess { super.process(); } - result() { + output() { return []; } }