feat: ppob callback
This commit is contained in:
@@ -5,6 +5,7 @@ import * as Joi from 'joi';
|
||||
import { UsersModule } from './users/users.module';
|
||||
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
|
||||
import { LoggerModule } from 'nestjs-pino';
|
||||
import { TransactionModule } from './transaction/transaction.module';
|
||||
import configuration from './config/configuration';
|
||||
|
||||
@Module({
|
||||
@@ -45,6 +46,7 @@ import configuration from './config/configuration';
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
UsersModule,
|
||||
TransactionModule,
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
NestFastifyApplication,
|
||||
} from '@nestjs/platform-fastify';
|
||||
import { AppModule } from './app.module';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import {ValidationPipe, VersioningType} from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { Logger } from 'nestjs-pino';
|
||||
|
||||
@@ -24,6 +24,9 @@ async function bootstrap() {
|
||||
whitelist: true,
|
||||
}),
|
||||
);
|
||||
app.enableVersioning({
|
||||
type: VersioningType.URI,
|
||||
});
|
||||
|
||||
const configService = app.get<ConfigService>(ConfigService);
|
||||
const port = configService.get<number>('port');
|
||||
|
||||
1
src/transaction/dto/create-transaction.dto.ts
Normal file
1
src/transaction/dto/create-transaction.dto.ts
Normal file
@@ -0,0 +1 @@
|
||||
export class CreateTransactionDto {}
|
||||
4
src/transaction/dto/update-transaction.dto.ts
Normal file
4
src/transaction/dto/update-transaction.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateTransactionDto } from './create-transaction.dto';
|
||||
|
||||
export class UpdateTransactionDto extends PartialType(CreateTransactionDto) {}
|
||||
1
src/transaction/entities/transaction.entity.ts
Normal file
1
src/transaction/entities/transaction.entity.ts
Normal file
@@ -0,0 +1 @@
|
||||
export class Transaction {}
|
||||
37
src/transaction/ppob_callback.controller.ts
Normal file
37
src/transaction/ppob_callback.controller.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Body,
|
||||
Patch,
|
||||
Param,
|
||||
Delete,
|
||||
HttpStatus,
|
||||
Logger,
|
||||
Req,
|
||||
} from '@nestjs/common';
|
||||
import { TransactionService } from './transaction.service';
|
||||
import { CreateTransactionDto } from './dto/create-transaction.dto';
|
||||
import { FastifyRequest } from 'fastify';
|
||||
|
||||
@Controller({
|
||||
path: 'ppob_callback',
|
||||
version: '1',
|
||||
})
|
||||
export class PpobCallbackController {
|
||||
private readonly logger = new Logger(PpobCallbackController.name);
|
||||
|
||||
constructor(private readonly transactionService: TransactionService) {}
|
||||
|
||||
@Get()
|
||||
get(@Req() request: FastifyRequest) {
|
||||
this.logger.log({
|
||||
requestQuery: request.query,
|
||||
});
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'success',
|
||||
};
|
||||
}
|
||||
}
|
||||
20
src/transaction/transaction.controller.spec.ts
Normal file
20
src/transaction/transaction.controller.spec.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { TransactionController } from './transaction.controller';
|
||||
import { TransactionService } from './transaction.service';
|
||||
|
||||
describe('TransactionController', () => {
|
||||
let controller: TransactionController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [TransactionController],
|
||||
providers: [TransactionService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<TransactionController>(TransactionController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
48
src/transaction/transaction.controller.ts
Normal file
48
src/transaction/transaction.controller.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Body,
|
||||
Patch,
|
||||
Param,
|
||||
Delete,
|
||||
} from '@nestjs/common';
|
||||
import { TransactionService } from './transaction.service';
|
||||
import { CreateTransactionDto } from './dto/create-transaction.dto';
|
||||
import { UpdateTransactionDto } from './dto/update-transaction.dto';
|
||||
|
||||
@Controller({
|
||||
path: 'transaction',
|
||||
version: '1',
|
||||
})
|
||||
export class TransactionController {
|
||||
constructor(private readonly transactionService: TransactionService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createTransactionDto: CreateTransactionDto) {
|
||||
return this.transactionService.create(createTransactionDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.transactionService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.transactionService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(
|
||||
@Param('id') id: string,
|
||||
@Body() updateTransactionDto: UpdateTransactionDto,
|
||||
) {
|
||||
return this.transactionService.update(+id, updateTransactionDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.transactionService.remove(+id);
|
||||
}
|
||||
}
|
||||
10
src/transaction/transaction.module.ts
Normal file
10
src/transaction/transaction.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TransactionService } from './transaction.service';
|
||||
import { TransactionController } from './transaction.controller';
|
||||
import { PpobCallbackController } from './ppob_callback.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [TransactionController, PpobCallbackController],
|
||||
providers: [TransactionService],
|
||||
})
|
||||
export class TransactionModule {}
|
||||
18
src/transaction/transaction.service.spec.ts
Normal file
18
src/transaction/transaction.service.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { TransactionService } from './transaction.service';
|
||||
|
||||
describe('TransactionService', () => {
|
||||
let service: TransactionService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [TransactionService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<TransactionService>(TransactionService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
26
src/transaction/transaction.service.ts
Normal file
26
src/transaction/transaction.service.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateTransactionDto } from './dto/create-transaction.dto';
|
||||
import { UpdateTransactionDto } from './dto/update-transaction.dto';
|
||||
|
||||
@Injectable()
|
||||
export class TransactionService {
|
||||
create(createTransactionDto: CreateTransactionDto) {
|
||||
return 'This action adds a new transaction';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all transaction`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} transaction`;
|
||||
}
|
||||
|
||||
update(id: number, updateTransactionDto: UpdateTransactionDto) {
|
||||
return `This action updates a #${id} transaction`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} transaction`;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,10 @@ import { UsersService } from './users.service';
|
||||
import { CreateUserDto } from './dto/create-user.dto';
|
||||
import { UpdateUserDto } from './dto/update-user.dto';
|
||||
|
||||
@Controller('users')
|
||||
@Controller({
|
||||
path: 'users',
|
||||
version: '1',
|
||||
})
|
||||
export class UsersController {
|
||||
constructor(private readonly usersService: UsersService) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user