mirror of
https://github.com/aditama-labs/nest-autocrud.git
synced 2024-11-22 03:16:21 +00:00
wip: default params
This commit is contained in:
parent
37d5f6b746
commit
87f951fe08
@ -16,7 +16,7 @@ export class PrismaCreateProcess
|
|||||||
this.dataResult = await this.getDelegate().create(this.dataInsert);
|
this.dataResult = await this.getDelegate().create(this.dataInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
result() {
|
output() {
|
||||||
this.dataResult;
|
this.dataResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ export class PrismaDeleteProcess
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
result() {
|
output() {
|
||||||
return this.dataResult;
|
return this.dataResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ export class PrismaListProcess extends PrismaProcess implements ListProcess {
|
|||||||
this.data = await this.getDelegate().findMany();
|
this.data = await this.getDelegate().findMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
result() {
|
output() {
|
||||||
return this.data;
|
return this.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ export class PrismaReadProcess extends PrismaProcess implements CreateProcess {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
result() {
|
output() {
|
||||||
return this.data;
|
return this.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ export class PrismaUpdateProcess
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
result() {
|
output() {
|
||||||
return this.dataResult;
|
return this.dataResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ export class DefaultExecutor {
|
|||||||
await this.process.after();
|
await this.process.after();
|
||||||
}
|
}
|
||||||
|
|
||||||
getResult(): any {
|
getOutput(): any {
|
||||||
return this.process.result();
|
return this.process.output();
|
||||||
}
|
}
|
||||||
|
|
||||||
static async bootstrap(process: ISkeletonProcess): Promise<any> {
|
static async bootstrap(process: ISkeletonProcess): Promise<any> {
|
||||||
const executor = new DefaultExecutor(process);
|
const executor = new DefaultExecutor(process);
|
||||||
await executor.execute();
|
await executor.execute();
|
||||||
return executor.getResult();
|
return executor.getOutput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
export interface ISkeletonCRUDController {
|
export interface ISkeletonCRUDController {
|
||||||
create();
|
create(body);
|
||||||
delete();
|
delete(id);
|
||||||
list();
|
list();
|
||||||
pagination();
|
pagination(params: { page?: number; limit?: number });
|
||||||
read(id);
|
read(id);
|
||||||
update();
|
update(id, body);
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,5 @@ export interface ISkeletonProcess {
|
|||||||
end();
|
end();
|
||||||
after();
|
after();
|
||||||
|
|
||||||
result();
|
output();
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ export class DefaultProcess implements ISkeletonProcess {
|
|||||||
async end(): Promise<any> {}
|
async end(): Promise<any> {}
|
||||||
async after(): Promise<any> {}
|
async after(): Promise<any> {}
|
||||||
|
|
||||||
result(): any {
|
output(): any {
|
||||||
return 'Hello World';
|
return 'Not Implemented Yet!';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
import {
|
||||||
CREATE_PROCESS,
|
CREATE_PROCESS,
|
||||||
DELETE_PROCESS,
|
DELETE_PROCESS,
|
||||||
@ -27,12 +36,12 @@ export class SkeletonCRUDController implements ISkeletonCRUDController {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
async create(): Promise<any> {
|
async create(@Body() body): Promise<any> {
|
||||||
return await DefaultExecutor.bootstrap(this.createProcess);
|
return await DefaultExecutor.bootstrap(this.createProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
async delete() {
|
async delete(@Param('id') id) {
|
||||||
return await DefaultExecutor.bootstrap(this.deleteProcess);
|
return await DefaultExecutor.bootstrap(this.deleteProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +51,9 @@ export class SkeletonCRUDController implements ISkeletonCRUDController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
async pagination() {
|
async pagination(
|
||||||
|
@Query() params: { page?: number; limit?: number } = { page: 1, limit: 10 },
|
||||||
|
) {
|
||||||
return await DefaultExecutor.bootstrap(this.paginationProcess);
|
return await DefaultExecutor.bootstrap(this.paginationProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +63,7 @@ export class SkeletonCRUDController implements ISkeletonCRUDController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Patch()
|
@Patch()
|
||||||
async update() {
|
async update(@Param('id') id, @Body() body) {
|
||||||
return await DefaultExecutor.bootstrap(this.updateProcess);
|
return await DefaultExecutor.bootstrap(this.updateProcess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@aditama-labs/nest-autocrud",
|
"name": "@aditama-labs/nest-autocrud",
|
||||||
"version": "0.0.22",
|
"version": "0.0.23",
|
||||||
"description": "NestJS Auto CRUD Library",
|
"description": "NestJS Auto CRUD Library",
|
||||||
"author": "Supan Adit Pratama",
|
"author": "Supan Adit Pratama",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
0
scripts/unix/release.sh
Normal file → Executable file
0
scripts/unix/release.sh
Normal file → Executable file
@ -1,5 +1,5 @@
|
|||||||
import { SkeletonCRUDController } from '@aditama-labs/nest-autocrud/skeleton';
|
import { SkeletonCRUDController } from '@aditama-labs/nest-autocrud/skeleton';
|
||||||
import { Controller } from '@nestjs/common';
|
import { Controller } from '@nestjs/common';
|
||||||
|
|
||||||
@Controller('hello')
|
@Controller('example')
|
||||||
export class AppController extends SkeletonCRUDController {}
|
export class AppController extends SkeletonCRUDController {}
|
||||||
|
@ -2,11 +2,12 @@ import { PrismaModule } from '@aditama-labs/nest-autocrud/prisma';
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { AppController } from './app.controller';
|
import { AppController } from './app.controller';
|
||||||
import { AppService } from './app.service';
|
import { AppService } from './app.service';
|
||||||
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
PrismaModule.forRoot({
|
PrismaModule.forRoot({
|
||||||
delegate: (prisma) => prisma.user,
|
delegate: (prisma: PrismaClient) => prisma.user,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
|
@ -6,7 +6,7 @@ export class AppListProcess extends PrismaListProcess {
|
|||||||
super.process();
|
super.process();
|
||||||
}
|
}
|
||||||
|
|
||||||
result() {
|
output() {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user