feat: ppob callback

This commit is contained in:
Hasta Ragil Saputra 2021-11-28 22:11:15 +07:00
parent f83aaec778
commit 770231744d
18 changed files with 192 additions and 19 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: nestjs-boilerplate-env
name: ppob-backend-env
namespace: empatnusabangsa-staging
type: Opaque
stringData:

View File

@ -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

View File

@ -1,5 +1,5 @@
{
"name": "sppbe-gas-meter",
"name": "ppob-backend",
"version": "0.0.1",
"description": "",
"author": "",

View File

@ -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 {}

View File

@ -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');

View File

@ -0,0 +1 @@
export class CreateTransactionDto {}

View File

@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateTransactionDto } from './create-transaction.dto';
export class UpdateTransactionDto extends PartialType(CreateTransactionDto) {}

View File

@ -0,0 +1 @@
export class Transaction {}

View 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',
};
}
}

View 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();
});
});

View 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);
}
}

View 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 {}

View 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();
});
});

View 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`;
}
}

View File

@ -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) {}