feat: ppob callback
This commit is contained in:
parent
f83aaec778
commit
770231744d
|
@ -1,6 +1,6 @@
|
||||||
variables:
|
variables:
|
||||||
REGISTRY_URL: registry-harbor.app.bangun-kreatif.com
|
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_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
|
VERSION_PRODUCTION: $CI_COMMIT_REF_NAME-$CI_PIPELINE_ID-$CI_COMMIT_SHORT_SHA-production
|
||||||
DOCKER_HOST: tcp://docker:2375
|
DOCKER_HOST: tcp://docker:2375
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: nestjs-boilerplate
|
name: ppob-backend
|
||||||
namespace: empatnusabangsa-staging
|
namespace: empatnusabangsa-staging
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: nestjs-boilerplate
|
app: ppob-backend
|
||||||
replicas: 1
|
replicas: 1
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: nestjs-boilerplate
|
app: ppob-backend
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: nestjs-boilerplate
|
- name: ppob-backend
|
||||||
image: registry-harbor.app.bangun-kreatif.com/empatnusabangsa/nestjs-boilerplate:<VERSION>
|
image: registry-harbor.app.bangun-kreatif.com/empatnusabangsa/ppob-backend:2
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5000
|
- containerPort: 5000
|
||||||
envFrom:
|
envFrom:
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: nestjs-boilerplate-env
|
name: ppob-backend-env
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: regcred
|
- name: regcred
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: networking.k8s.io/v1
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
name: nestjs-boilerplate
|
name: ppob-backend
|
||||||
namespace: empatnusabangsa-staging
|
namespace: empatnusabangsa-staging
|
||||||
annotations:
|
annotations:
|
||||||
kubernetes.io/ingress.class: "traefik"
|
kubernetes.io/ingress.class: "traefik"
|
||||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- host: "nestjs-boilerplate.k3s.bangun-kreatif.com"
|
- host: "ppob-backend.k3s.bangun-kreatif.com"
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- pathType: Prefix
|
- pathType: Prefix
|
||||||
path: /
|
path: /
|
||||||
backend:
|
backend:
|
||||||
service:
|
service:
|
||||||
name: nestjs-boilerplate
|
name: ppob-backend
|
||||||
port:
|
port:
|
||||||
number: 5000
|
number: 5000
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- "nestjs-boilerplate.k3s.bangun-kreatif.com"
|
- "ppob-backend.k3s.bangun-kreatif.com"
|
||||||
secretName: nestjs-boilerplate-k3s-bangun-kreatif-com-tls
|
secretName: ppob-backend-k3s-bangun-kreatif-com-tls
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: nestjs-boilerplate-env
|
name: ppob-backend-env
|
||||||
namespace: empatnusabangsa-staging
|
namespace: empatnusabangsa-staging
|
||||||
type: Opaque
|
type: Opaque
|
||||||
stringData:
|
stringData:
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: nestjs-boilerplate
|
name: ppob-backend
|
||||||
namespace: empatnusabangsa-staging
|
namespace: empatnusabangsa-staging
|
||||||
labels:
|
labels:
|
||||||
run: nestjs-boilerplate
|
run: ppob-backend
|
||||||
spec:
|
spec:
|
||||||
ports:
|
ports:
|
||||||
- port: 5000
|
- port: 5000
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
selector:
|
selector:
|
||||||
app: nestjs-boilerplate
|
app: ppob-backend
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "sppbe-gas-meter",
|
"name": "ppob-backend",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|
|
@ -5,6 +5,7 @@ import * as Joi from 'joi';
|
||||||
import { UsersModule } from './users/users.module';
|
import { UsersModule } from './users/users.module';
|
||||||
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
|
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
|
||||||
import { LoggerModule } from 'nestjs-pino';
|
import { LoggerModule } from 'nestjs-pino';
|
||||||
|
import { TransactionModule } from './transaction/transaction.module';
|
||||||
import configuration from './config/configuration';
|
import configuration from './config/configuration';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
@ -45,6 +46,7 @@ import configuration from './config/configuration';
|
||||||
inject: [ConfigService],
|
inject: [ConfigService],
|
||||||
}),
|
}),
|
||||||
UsersModule,
|
UsersModule,
|
||||||
|
TransactionModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
NestFastifyApplication,
|
NestFastifyApplication,
|
||||||
} from '@nestjs/platform-fastify';
|
} from '@nestjs/platform-fastify';
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
import { ValidationPipe } from '@nestjs/common';
|
import {ValidationPipe, VersioningType} from '@nestjs/common';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { Logger } from 'nestjs-pino';
|
import { Logger } from 'nestjs-pino';
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@ async function bootstrap() {
|
||||||
whitelist: true,
|
whitelist: true,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
app.enableVersioning({
|
||||||
|
type: VersioningType.URI,
|
||||||
|
});
|
||||||
|
|
||||||
const configService = app.get<ConfigService>(ConfigService);
|
const configService = app.get<ConfigService>(ConfigService);
|
||||||
const port = configService.get<number>('port');
|
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 { CreateUserDto } from './dto/create-user.dto';
|
||||||
import { UpdateUserDto } from './dto/update-user.dto';
|
import { UpdateUserDto } from './dto/update-user.dto';
|
||||||
|
|
||||||
@Controller('users')
|
@Controller({
|
||||||
|
path: 'users',
|
||||||
|
version: '1',
|
||||||
|
})
|
||||||
export class UsersController {
|
export class UsersController {
|
||||||
constructor(private readonly usersService: UsersService) {}
|
constructor(private readonly usersService: UsersService) {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user