Skip to content

Commit

Permalink
Merge pull request #169 from samchon/features/nestia
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
samchon authored Oct 19, 2023
2 parents 93de832 + 71776ee commit 8670275
Show file tree
Hide file tree
Showing 28 changed files with 100 additions and 78 deletions.
5 changes: 4 additions & 1 deletion packages/fake-iamport-server/nestia.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { INestiaConfig } from "@nestia/sdk";
import { NestFactory } from "@nestjs/core";

import { FakeIamportModule } from "./src/FakeIamportModule";

const NESTIA_CONFIG: INestiaConfig = {
input: "src/controllers",
input: async () => NestFactory.create(await FakeIamportModule()),
output: "src/api",
simulate: true,
distribute: "../iamport-server-api",
Expand Down
10 changes: 5 additions & 5 deletions packages/fake-iamport-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fake-iamport-server",
"version": "4.0.3",
"version": "5.0.0",
"description": "Fake iamport server for testing",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -39,7 +39,7 @@
},
"homepage": "https://github.com/samchon/fake-iamport-server",
"devDependencies": {
"@nestia/sdk": "^2.2.3",
"@nestia/sdk": "^2.3.0",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"@types/atob": "^2.1.2",
"@types/btoa": "^1.2.3",
Expand All @@ -60,13 +60,13 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@nestia/core": "^2.2.3",
"@nestia/core": "^2.3.0",
"@nestia/e2e": "^0.3.6",
"@nestia/fetcher": "^2.2.3",
"@nestia/fetcher": "^2.3.0",
"source-map-support": "^0.5.19",
"tstl": "^2.5.13",
"typescript-transform-paths": "^3.4.6",
"typia": "^5.2.2",
"typia": "^5.2.3",
"uuid": "^9.0.0"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions packages/fake-iamport-server/src/FakeIamportBackend.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import core from "@nestia/core";
import { NestFactory } from "@nestjs/core";
import {
FastifyAdapter,
NestFastifyApplication,
} from "@nestjs/platform-fastify";

import { FakeIamportConfiguration } from "./FakeIamportConfiguration";
import { FakeIamportModule } from "./FakeIamportModule";

/**
* Fake 아임포트 서버의 백엔드 프로그램.
Expand All @@ -24,7 +24,7 @@ export class FakeIamportBackend {
//----
// MOUNT CONTROLLERS
this.application_ = await NestFactory.create(
await core.DynamicModule.mount(`${__dirname}/controllers`),
await FakeIamportModule(),
new FastifyAdapter(),
{ logger: false },
);
Expand Down
4 changes: 4 additions & 0 deletions packages/fake-iamport-server/src/FakeIamportModule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { DynamicModule } from "@nestia/core";

export const FakeIamportModule = () =>
DynamicModule.mount(__dirname + "/controllers");
5 changes: 4 additions & 1 deletion packages/fake-toss-payments-server/nestia.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type { INestiaConfig } from "@nestia/sdk";
import { NestFactory } from "@nestjs/core";

import { FakeTossModule } from "./src/FakeTossModule";

const NESTIA_CONFIG: INestiaConfig = {
simulate: true,
input: "src/controllers",
input: async () => NestFactory.create(await FakeTossModule()),
output: "src/api",
distribute: "../toss-payments-server-api",
swagger: {
Expand Down
8 changes: 4 additions & 4 deletions packages/fake-toss-payments-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fake-toss-payments-server",
"version": "4.0.3",
"version": "5.0.0",
"description": "Fake toss-payments server for testing",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -40,7 +40,7 @@
"homepage": "https://github.com/samchon/fake-toss-payments-server",
"devDependencies": {
"@nestia/e2e": "^0.3.6",
"@nestia/sdk": "^2.2.3",
"@nestia/sdk": "^2.3.0",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"@types/atob": "^2.1.2",
"@types/btoa": "^1.2.3",
Expand All @@ -62,13 +62,13 @@
"typescript-transform-paths": "^3.4.6"
},
"dependencies": {
"@nestia/core": "^2.2.3",
"@nestia/core": "^2.3.0",
"atob": "^2.1.2",
"btoa": "^1.2.1",
"serialize-error": "^4.1.0",
"source-map-support": "^0.5.19",
"tstl": "^2.5.13",
"typia": "^5.2.2",
"typia": "^5.2.3",
"uuid": "^9.0.0"
},
"keywords": [
Expand Down
8 changes: 4 additions & 4 deletions packages/fake-toss-payments-server/src/FakeTossBackend.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import core from "@nestia/core";
import { NestFactory } from "@nestjs/core";
import {
FastifyAdapter,
NestFastifyApplication,
} from "@nestjs/platform-fastify";

import { TossFakeConfiguration } from "./FakeTossConfiguration";
import { FakeTossConfiguration } from "./FakeTossConfiguration";
import { FakeTossModule } from "./FakeTossModule";

/**
* Fake 토스 페이먼츠 서버의 백엔드 프로그램.
Expand All @@ -24,14 +24,14 @@ export class FakeTossBackend {
//----
// MOUNT CONTROLLERS
this.application_ = await NestFactory.create(
await core.DynamicModule.mount(`${__dirname}/controllers`),
await FakeTossModule(),
new FastifyAdapter(),
{ logger: false },
);

// DO OPEN
this.application_.enableCors();
await this.application_.listen(TossFakeConfiguration.API_PORT);
await this.application_.listen(FakeTossConfiguration.API_PORT);

//----
// POST-PROCESSES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (EXTENSION === "js") require("source-map-support").install();
*
* @author Samchon
*/
export namespace TossFakeConfiguration {
export namespace FakeTossConfiguration {
/**
* @internal
*/
Expand Down
4 changes: 4 additions & 0 deletions packages/fake-toss-payments-server/src/FakeTossModule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { DynamicModule } from "@nestia/core";

export const FakeTossModule = () =>
DynamicModule.mount(`${__dirname}/controllers`);
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { ITossCashReceipt } from "toss-payments-server-api/lib/structures/ITossC
import { ITossPayment } from "toss-payments-server-api/lib/structures/ITossPayment";
import { ITossPaymentWebhook } from "toss-payments-server-api/lib/structures/ITossPaymentWebhook";

import { TossFakeConfiguration } from "../FakeTossConfiguration";
import { FakeTossConfiguration } from "../FakeTossConfiguration";
import { VolatileMap } from "../utils/VolatileMap";

export namespace FakeTossStorage {
export const payments: VolatileMap<string, ITossPayment> = new VolatileMap(
TossFakeConfiguration.EXPIRATION,
FakeTossConfiguration.EXPIRATION,
);
export const billings: VolatileMap<
string,
[ITossBilling, ITossBilling.IStore]
> = new VolatileMap(TossFakeConfiguration.EXPIRATION);
> = new VolatileMap(FakeTossConfiguration.EXPIRATION);
export const cash_receipts: VolatileMap<string, ITossCashReceipt> =
new VolatileMap(TossFakeConfiguration.EXPIRATION);
new VolatileMap(FakeTossConfiguration.EXPIRATION);
export const webhooks: VolatileMap<string, ITossPaymentWebhook> =
new VolatileMap(TossFakeConfiguration.EXPIRATION);
new VolatileMap(FakeTossConfiguration.EXPIRATION);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as nest from "@nestjs/common";
import atob from "atob";
import * as fastify from "fastify";

import { TossFakeConfiguration } from "../FakeTossConfiguration";
import { FakeTossConfiguration } from "../FakeTossConfiguration";

export namespace FakeTossUserAuth {
export function authorize(request: fastify.FastifyRequest): void {
Expand All @@ -16,7 +16,7 @@ export namespace FakeTossUserAuth {
token = atob(token);

if (
TossFakeConfiguration.authorize(
FakeTossConfiguration.authorize(
token.substr(0, token.length - 1),
) === false
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ITossPaymentWebhook } from "toss-payments-server-api/lib/structures/ITossPaymentWebhook";

import { TossFakeConfiguration } from "../FakeTossConfiguration";
import { FakeTossConfiguration } from "../FakeTossConfiguration";

// POLYFILL FOR NODE
if (
Expand All @@ -13,7 +13,7 @@ if (

export namespace FakeTossWebhookProvider {
export async function webhook(input: ITossPaymentWebhook): Promise<void> {
await fetch(TossFakeConfiguration.WEBHOOK_URL, {
await fetch(FakeTossConfiguration.WEBHOOK_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
8 changes: 4 additions & 4 deletions packages/fake-toss-payments-server/src/utils/ErrorUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import serializeError from "serialize-error";
import { randint } from "tstl/algorithm/random";
import { Singleton } from "tstl/thread/Singleton";

import { TossFakeConfiguration } from "../FakeTossConfiguration";
import { FakeTossConfiguration } from "../FakeTossConfiguration";

export namespace ErrorUtil {
export function toJSON(err: any): object {
Expand Down Expand Up @@ -32,7 +32,7 @@ export namespace ErrorUtil {

await directory.get();
await fs.promises.writeFile(
`${TossFakeConfiguration.ASSETS}/logs/errors/${prefix}_${fileName}.log`,
`${FakeTossConfiguration.ASSETS}/logs/errors/${prefix}_${fileName}.log`,
content,
"utf8",
);
Expand All @@ -47,10 +47,10 @@ function cipher(val: number): string {

const directory = new Singleton(async () => {
try {
await fs.promises.mkdir(`${TossFakeConfiguration.ASSETS}/logs`);
await fs.promises.mkdir(`${FakeTossConfiguration.ASSETS}/logs`);
} catch {}

try {
await fs.promises.mkdir(`${TossFakeConfiguration.ASSETS}/logs/errors`);
await fs.promises.mkdir(`${FakeTossConfiguration.ASSETS}/logs/errors`);
} catch {}
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import { IPointer } from "tstl/functional/IPointer";
import { assert } from "typia";
import { v4 } from "uuid";

import { TossFakeConfiguration } from "../../src/FakeTossConfiguration";
import { FakeTossConfiguration } from "../../src/FakeTossConfiguration";
import { FakeTossStorage } from "../../src/providers/FakeTossStorage";
import { AdvancedRandomGenerator } from "../internal/AdvancedRandomGenerator";
import { TestConnection } from "../internal/TestConnection";

export async function test_fake_storage_capacity(): Promise<void> {
const capacity: number = TossFakeConfiguration.EXPIRATION.capacity;
const capacity: number = FakeTossConfiguration.EXPIRATION.capacity;

FakeTossStorage.payments.clear();
FakeTossStorage.billings.clear();
TossFakeConfiguration.EXPIRATION.capacity = 1;
FakeTossConfiguration.EXPIRATION.capacity = 1;

const previous: IPointer<string | null> = { value: null };
for (let i: number = 0; i < 10; ++i) {
Expand Down Expand Up @@ -83,5 +83,5 @@ export async function test_fake_storage_capacity(): Promise<void> {
previous.value = payment.paymentKey;
}

TossFakeConfiguration.EXPIRATION.capacity = capacity;
FakeTossConfiguration.EXPIRATION.capacity = capacity;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { sleep_for } from "tstl/thread/global";
import { assert } from "typia";
import { v4 } from "uuid";

import { TossFakeConfiguration } from "../../src/FakeTossConfiguration";
import { FakeTossConfiguration } from "../../src/FakeTossConfiguration";
import { FakeTossStorage } from "../../src/providers/FakeTossStorage";
import { AdvancedRandomGenerator } from "../internal/AdvancedRandomGenerator";
import { TestConnection } from "../internal/TestConnection";

export async function test_fake_storage_expiration_time(): Promise<void> {
const time: number = TossFakeConfiguration.EXPIRATION.time;
const time: number = FakeTossConfiguration.EXPIRATION.time;
FakeTossStorage.payments.clear();
TossFakeConfiguration.EXPIRATION.time = 1;
FakeTossConfiguration.EXPIRATION.time = 1;

const previous: IPointer<string | null> = { value: null };
await ArrayUtil.asyncRepeat(10)(async () => {
Expand Down Expand Up @@ -51,5 +51,5 @@ export async function test_fake_storage_expiration_time(): Promise<void> {
);
previous.value = payment.paymentKey;
});
TossFakeConfiguration.EXPIRATION.time = time;
FakeTossConfiguration.EXPIRATION.time = time;
}
4 changes: 2 additions & 2 deletions packages/fake-toss-payments-server/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DynamicExecutor } from "@nestia/e2e";

import { FakeTossBackend } from "../src/FakeTossBackend";
import { TossFakeConfiguration } from "../src/FakeTossConfiguration";
import { FakeTossConfiguration } from "../src/FakeTossConfiguration";
import toss from "../src/api";

async function main(): Promise<void> {
Expand All @@ -11,7 +11,7 @@ async function main(): Promise<void> {

// CONNECTION INFO
const connection: toss.IConnection = {
host: `http://127.0.0.1:${TossFakeConfiguration.API_PORT}`,
host: `http://127.0.0.1:${FakeTossConfiguration.API_PORT}`,
};

// DO TEST
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import btoa from "btoa";

import { TossFakeConfiguration } from "../../src/FakeTossConfiguration";
import { FakeTossConfiguration } from "../../src/FakeTossConfiguration";
import toss from "../../src/api";

export namespace TestConnection {
export const FAKE: toss.IConnection = {
host: `http://127.0.0.1:${TossFakeConfiguration.API_PORT}`,
host: `http://127.0.0.1:${FakeTossConfiguration.API_PORT}`,
headers: {
Authorization: `Basic ${btoa(
"test_ak_ZORzdMaqN3wQd5k6ygr5AkYXQGwy:",
Expand Down
6 changes: 3 additions & 3 deletions packages/iamport-server-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iamport-server-api",
"version": "4.0.3",
"version": "5.0.0",
"description": "API for Iamport Server",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -34,7 +34,7 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@nestia/fetcher": "^2.2.3",
"typia": "^5.2.2"
"@nestia/fetcher": "^2.3.0",
"typia": "^5.2.3"
}
}
2 changes: 1 addition & 1 deletion packages/iamport-server-api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"info": {
"title": "Iamport API",
"description": "Built by [fake-iamport-server](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server) with [nestia](https://github.com/samchon/nestia)",
"version": "4.0.3",
"version": "5.0.0",
"license": {
"name": "MIT"
}
Expand Down
10 changes: 5 additions & 5 deletions packages/payment-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samchon/payment-api",
"version": "4.0.3",
"version": "5.0.0",
"description": "API for Payment Backend",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -34,9 +34,9 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@nestia/fetcher": "^2.2.3",
"iamport-server-api": "^4.0.3",
"toss-payments-server-api": "^4.0.3",
"typia": "^5.2.2"
"@nestia/fetcher": "^2.3.0",
"iamport-server-api": "^5.0.0",
"toss-payments-server-api": "^5.0.0",
"typia": "^5.2.3"
}
}
Loading

0 comments on commit 8670275

Please sign in to comment.