feat: ppob callback
This commit is contained in:
parent
f83aaec778
commit
770231744d
|
@ -1,6 +1,6 @@
|
|||
variables:
|
||||
REGISTRY_URL: registry-harbor.app.bangun-kreatif.com
|
||||
REGISTRY_IMAGE: $REGISTRY_URL/empatnusabangsa/nestjs-boilerplate
|
||||
REGISTRY_IMAGE: $REGISTRY_URL/empatnusabangsa/ppob-backend
|
||||
VERSION_STAGING: $CI_COMMIT_REF_NAME-$CI_PIPELINE_ID-$CI_COMMIT_SHORT_SHA
|
||||
VERSION_PRODUCTION: $CI_COMMIT_REF_NAME-$CI_PIPELINE_ID-$CI_COMMIT_SHORT_SHA-production
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nestjs-boilerplate
|
||||
name: ppob-backend
|
||||
namespace: empatnusabangsa-staging
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nestjs-boilerplate
|
||||
app: ppob-backend
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nestjs-boilerplate
|
||||
app: ppob-backend
|
||||
spec:
|
||||
containers:
|
||||
- name: nestjs-boilerplate
|
||||
image: registry-harbor.app.bangun-kreatif.com/empatnusabangsa/nestjs-boilerplate:<VERSION>
|
||||
- name: ppob-backend
|
||||
image: registry-harbor.app.bangun-kreatif.com/empatnusabangsa/ppob-backend:2
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: nestjs-boilerplate-env
|
||||
name: ppob-backend-env
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: nestjs-boilerplate
|
||||
name: ppob-backend
|
||||
namespace: empatnusabangsa-staging
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "traefik"
|
||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||
spec:
|
||||
rules:
|
||||
- host: "nestjs-boilerplate.k3s.bangun-kreatif.com"
|
||||
- host: "ppob-backend.k3s.bangun-kreatif.com"
|
||||
http:
|
||||
paths:
|
||||
- pathType: Prefix
|
||||
path: /
|
||||
backend:
|
||||
service:
|
||||
name: nestjs-boilerplate
|
||||
name: ppob-backend
|
||||
port:
|
||||
number: 5000
|
||||
tls:
|
||||
- hosts:
|
||||
- "nestjs-boilerplate.k3s.bangun-kreatif.com"
|
||||
secretName: nestjs-boilerplate-k3s-bangun-kreatif-com-tls
|
||||
- "ppob-backend.k3s.bangun-kreatif.com"
|
||||
secretName: ppob-backend-k3s-bangun-kreatif-com-tls
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: nestjs-boilerplate-env
|
||||
name: ppob-backend-env
|
||||
namespace: empatnusabangsa-staging
|
||||
type: Opaque
|
||||
stringData:
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nestjs-boilerplate
|
||||
name: ppob-backend
|
||||
namespace: empatnusabangsa-staging
|
||||
labels:
|
||||
run: nestjs-boilerplate
|
||||
run: ppob-backend
|
||||
spec:
|
||||
ports:
|
||||
- port: 5000
|
||||
protocol: TCP
|
||||
selector:
|
||||
app: nestjs-boilerplate
|
||||
app: ppob-backend
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "sppbe-gas-meter",
|
||||
"name": "ppob-backend",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
|
|
|
@ -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) {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user