Skip to content

Commit

Permalink
Merge pull request #62 from plus-tdd/hotfix/alarm
Browse files Browse the repository at this point in the history
Hotfix/alarm
  • Loading branch information
codesejin authored Jul 28, 2023
2 parents 2585580 + ece3a87 commit 37cd37b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/__tests__/payment/payment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { PaymentService } from "../../module/payment/domain/payment.service";
import { PaymentInfo } from "../../module/payment/domain/payment.model";
import { PaymentRepository, TestPaymentRepository } from "../../module/payment/domain/payment.repository";
import { TestExternalPaymentSDK } from "../../module/payment/domain/payment.external.sdk";
import { PaymentRequestDto } from "src/module/payment/api/payment.save.request.dto";
import { AlarmService } from "src/module/alarm/alarm.service";
import { AlarmService, TestAlarmService } from '../../module/alarm/alarm.service';

// Completed request Info
// const validatedRequest: PaymentCardRequestInfo = {
Expand Down Expand Up @@ -99,7 +98,7 @@ describe('결제 시 필요한 카드 정보 검증 TestSuite', () => {
const endDateIsEmpty: PaymentInfo = {
userId : 1,
cardNum: 1234567812345678,
endDate: undefined, // string이 undefined 일 경우
endDate: '', // string이 undefined 일 경우
cvc: 345,
cardCompany: CardCompany.Kookmin,
price: 10000
Expand Down
23 changes: 16 additions & 7 deletions src/logger/logger.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ export class LoggerMiddleware implements NestMiddleware {

// 로그 남기기
this.logger.info(
`${method} ${url} ${statusCode}\n[REQUEST] \nParams: ${JSON.stringify(
params,
)}Query: ${JSON.stringify(query)}Body: ${JSON.stringify(
body,
)}Headers: ${JSON.stringify(
headers,
)}\n[RESPONSE]\nStatus:${statusCode}\nBody: ${responseBody}`,
`${method} ${url} ${statusCode}\n ========================[REQUEST]========================\n` +
`Params: ${JSON.stringify(params, null, 2)}\n` +
`Query: ${JSON.stringify(query, null, 2).replace(/,/g, ',\n')}\n` +
`Body: { \n` +
Object.keys(body)
.map((key) => ` "${key}": "${body[key]}"`)
.join(",\n") +
`\n}\n` +
`Headers: {\n` +
Object.keys(headers)
.map((key) => ` "${key}": "${headers[key]}"`)
.join(",\n") +
`\n}\n` +
`========================[RESPONSE]========================\n` +
`Status:${statusCode}\n` +
`Body: ${JSON.stringify(JSON.parse(responseBody), null, '').replace(/,/g, ',\n')}`
);
}.bind(this);

Expand Down
7 changes: 5 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import Logger from './logger';
import { HttpExceptionFilter } from './http-exception.filter';
import * as moment from 'moment-timezone';

import express from 'express';
import { join } from 'path';
import { NestExpressApplication } from '@nestjs/platform-express';
declare const module: any;

async function bootstrap() {
Expand All @@ -18,6 +20,7 @@ async function bootstrap() {
app.useGlobalFilters(new HttpExceptionFilter());

const port = process.env.PORT || 3000;

const config = new DocumentBuilder()
.setTitle('animalNest Api')
.setDescription('동물병원 예약 시나리오 개발을 위한 API문서')
Expand All @@ -28,7 +31,7 @@ async function bootstrap() {

await app.listen(port);
console.log(`listening on port ${port}`);
logger.info('Hello, World!!!!! 로그 성공', 'MAIN');


if (module.hot) {
module.hot.accept();
Expand Down
1 change: 1 addition & 0 deletions src/module/auth/domain/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class AuthService {
{ secret: process.env.JWT_SECRET_KEY, expiresIn: '600s' },
);
return {
userId: user.id,
accessToken,
};
}
Expand Down
8 changes: 7 additions & 1 deletion src/module/payment/domain/payment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import { PaymentRepository } from './payment.repository';
import { AlarmData } from 'src/module/alarm/alarm.service';
import Logger from 'src/logger';
import { InvalidPaymentInfoException } from '../payment.error';
import axios from 'axios'; // http request를 만들기 우한 라이브러리

@Injectable() // 비즈니스 로직으로 분리
export class PaymentService {

private logger;

private readonly tossUrl = 'https://api.tosspayments.com/v1/payments/';
private readonly secretKey = process.env.TOSS_TEST_KEY;

constructor(
@Inject('PaymentRepository')
private readonly repository: PaymentRepository,
Expand Down Expand Up @@ -51,6 +54,9 @@ export class PaymentService {
return savePaymentInfo;
}




public async getPaymenList(userId: number): Promise<Payment[]> {

const paymentList: Payment[] = await this.repository.findPaymentsByUserId(userId);
Expand Down
1 change: 1 addition & 0 deletions src/module/user/domain/user.output.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export class UserOutPutDto {
password: string;
}
export class LoginOutputDto {
readonly userId: number;
readonly accessToken: string;
}

0 comments on commit 37cd37b

Please sign in to comment.