From 104bbf71e0e703333c5427b1a603166c1121c26b Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Sun, 14 Jul 2024 02:50:18 +0900 Subject: [PATCH 1/2] Publish both CJS and ESM. Configured rollup to every monorepo packages, so that builds and publishes both CJS and ESM. Also, bumped up NestJS related dependencies. --- .github/workflows/build.yml | 6 +- deploy/publish.js | 129 ++++++++++++------ package.json | 2 +- packages/fake-iamport-server/README.md | 2 +- packages/fake-iamport-server/nestia.config.ts | 4 +- packages/fake-iamport-server/package.json | 33 +++-- .../packages/api}/README.md | 2 +- .../packages/api/package.json | 29 ++++ .../packages/api/rollup.config.js | 29 ++++ .../packages/api}/swagger.json | 57 ++++---- .../packages/api/tsconfig.json | 15 ++ packages/fake-iamport-server/rollup.config.js | 29 ++++ .../src/api/utils/NestiaSimulator.ts | 70 ---------- packages/fake-iamport-server/test/index.ts | 14 +- packages/fake-toss-payments-server/README.md | 4 +- .../nestia.config.ts | 4 +- .../fake-toss-payments-server/package.json | 32 +++-- .../packages/api}/README.md | 2 +- .../packages/api}/package.json | 11 +- .../packages/api/rollup.config.js | 29 ++++ .../packages/api}/swagger.json | 30 ++-- .../packages/api/tsconfig.json | 15 ++ .../rollup.config.js | 29 ++++ .../fake-toss-payments-server/test/index.ts | 14 +- packages/iamport-server-api/package.json | 40 ------ packages/iamport-server-api/tsconfig.json | 97 ------------- packages/payment-api/tsconfig.json | 97 ------------- packages/payment-backend/nestia.config.ts | 4 +- packages/payment-backend/package.json | 38 +++--- .../packages/api}/README.md | 0 .../packages/api}/package.json | 16 ++- .../packages/api/rollup.config.js | 29 ++++ .../packages/api}/swagger.json | 10 +- .../packages/api/tsconfig.json | 15 ++ packages/payment-backend/rollup.config.js | 29 ++++ .../api/functional/payments/internal/index.ts | 2 - .../api/functional/payments/webhooks/index.ts | 4 - packages/payment-backend/test/index.ts | 19 ++- .../test/internal/StopWatch.ts | 19 +++ packages/payment-backend/test/webpack.ts | 14 +- .../toss-payments-server-api/tsconfig.json | 97 ------------- 41 files changed, 552 insertions(+), 569 deletions(-) rename packages/{iamport-server-api => fake-iamport-server/packages/api}/README.md (96%) create mode 100644 packages/fake-iamport-server/packages/api/package.json create mode 100644 packages/fake-iamport-server/packages/api/rollup.config.js rename packages/{iamport-server-api => fake-iamport-server/packages/api}/swagger.json (98%) create mode 100644 packages/fake-iamport-server/packages/api/tsconfig.json create mode 100644 packages/fake-iamport-server/rollup.config.js delete mode 100644 packages/fake-iamport-server/src/api/utils/NestiaSimulator.ts rename packages/{toss-payments-server-api => fake-toss-payments-server/packages/api}/README.md (95%) rename packages/{toss-payments-server-api => fake-toss-payments-server/packages/api}/package.json (79%) create mode 100644 packages/fake-toss-payments-server/packages/api/rollup.config.js rename packages/{toss-payments-server-api => fake-toss-payments-server/packages/api}/swagger.json (99%) create mode 100644 packages/fake-toss-payments-server/packages/api/tsconfig.json create mode 100644 packages/fake-toss-payments-server/rollup.config.js delete mode 100644 packages/iamport-server-api/package.json delete mode 100644 packages/iamport-server-api/tsconfig.json delete mode 100644 packages/payment-api/tsconfig.json rename packages/{payment-api => payment-backend/packages/api}/README.md (100%) rename packages/{payment-api => payment-backend/packages/api}/package.json (72%) create mode 100644 packages/payment-backend/packages/api/rollup.config.js rename packages/{payment-api => payment-backend/packages/api}/swagger.json (99%) create mode 100644 packages/payment-backend/packages/api/tsconfig.json create mode 100644 packages/payment-backend/rollup.config.js create mode 100644 packages/payment-backend/test/internal/StopWatch.ts delete mode 100644 packages/toss-payments-server-api/tsconfig.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f14fb3..f5c65a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,8 +16,8 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 - - name: Setup PNPM - run: npm i -g pnpm && pnpm install + - name: Setup Station + run: npm install - name: Test Packages - run: pnpm run test \ No newline at end of file + run: npm run test \ No newline at end of file diff --git a/deploy/publish.js b/deploy/publish.js index 5c54506..dff5bbb 100644 --- a/deploy/publish.js +++ b/deploy/publish.js @@ -2,7 +2,23 @@ const cp = require("child_process"); const fs = require("fs"); const path = require("path"); -const packages = fs.readdirSync(`${__dirname}/../packages`); +const PACKAGES = [ + { + location: "fake-iamport-server", + name: "fake-iamport-server", + api: "iamport-server-api", + }, + { + location: "fake-toss-payments-server", + name: "fake-toss-payments-server", + api: "toss-payments-server-api", + }, + { + location: "payment-backend", + name: "@samchon/payment-backend", + api: "@samchon/payment-api", + }, +]; const execute = (cwd, stdio = "ignore") => @@ -11,52 +27,96 @@ const execute = cp.execSync(command, { cwd, stdio }); }; -const deploy = (tag) => (version) => (name) => { +const deploy = (tag) => (version) => (pack) => { console.log("-----------------------------------------"); - console.log(name.toUpperCase()); + console.log(pack.location.toUpperCase()); console.log("-----------------------------------------"); // CHANGE PACKAGE.JSON INFO - const directory = `${__dirname}/../packages/${name}`; - const file = `${directory}/package.json`; - const info = JSON.parse(fs.readFileSync(file, "utf8")); + const location = `${__dirname}/../packages/${pack.location}`; + const info = JSON.parse( + fs.readFileSync(`${location}/package.json`, "utf8"), + ); info.version = version; for (const record of [info.dependencies ?? {}, info.devDependencies ?? {}]) - for (const key of Object.keys(record)) - if (packages.includes(key.replace("@samchon/", ""))) { - if (tag === "tgz" && fs.existsSync(`${directory}/node_modules/${key}`)) - execute(directory)(`pnpm uninstall ${key}`); + for (const key of Object.keys(record)) { + const backend = PACKAGES.find(p => p.name === key); + const api = PACKAGES.find(p => p.api === key); + if (backend !== undefined) { + if (tag === "tgz" && fs.existsSync(`${location}/node_modules/${key}`)) + execute(location)(`npm uninstall ${key}`); record[key] = tag === "tgz" - ? path.resolve( - `${__dirname}/../packages/${key.replace( - "@samchon/", - "", - )}/${key}-${version}.tgz`, - ) + ? path.resolve(`${__dirname}/../packages/${backend.location}/${key}-${version}.tgz`) : `^${version}`; } + else if (api !== undefined) { + if (tag === "tgz" && fs.existsSync(`${location}/node_modules/${key}`)) + execute(location)(`npm uninstall ${key}`); + record[key] = + tag === "tgz" + ? path.resolve(`${__dirname}/../packages/${api.location}/packages/api/${key}-${version}.tgz`) + : `^${version}`; + } + } // SETUP UPDATED DEPENDENCIES - fs.writeFileSync(file, JSON.stringify(info, null, 2), "utf8"); - execute(directory)(`pnpm install`); - execute(directory)(`npm run build`); + fs.writeFileSync( + `${location}/package.json`, + JSON.stringify(info, null, 2), + "utf8", + ); + execute(location)(`npm install`); + execute(location)(`npm run build`); // RUN TEST PROGRAM - if (name === "payment-backend") { - execute(directory)(`npm run schema`); - execute(directory, "inherit")(`npm run test -- --reset true`); - } else if (fs.existsSync(`${directory}/test`)) - execute(directory, "inherit")(`npm run test`); + if (pack.name === "@samchon/payment-backend") { + execute(location)(`npm run schema`); + execute(location, "inherit")(`npm run test -- --reset true`); + } else if (fs.existsSync(`${location}/test`)) + execute(location, "inherit")(`npm run test`); - // BUILD SWAGGER FILE - if (name.includes("api") === false) - execute(directory)(`npm run build:swagger`); + // PUBLISH BACKEND + if (tag === "tgz") execute(location)(`npm pack`); + else execute(location)(`npm publish --tag ${tag} --access public`); - // PUBLISH (OR PACK) - if (tag === "tgz") execute(directory)(`npm pack`); - else execute(directory)(`npm publish --tag ${tag} --access public`); + // PUBLISH API + const apiInfo = JSON.parse( + fs.readFileSync( + `${location}/packages/api/package.json`, + "utf8", + ), + ); + apiInfo.version = version; + if (pack.api === "@samchon/payment-api") { + apiInfo.dependencies["iamport-server-api"] = tag === "tgz" + ? path.resolve( + `${__dirname}/../packages/fake-iamport-server/packages/api/iamport-server-api-${version}.tgz` + ) + : `^${version}`; + apiInfo.dependencies["toss-payments-server-api"] = tag === "tgz" + ? path.resolve( + `${__dirname}/../packages/fake-toss-payments-server/packages/api/toss-payments-server-api-${version}.tgz` + ) + : `^${version}`; + } + fs.writeFileSync( + `${location}/packages/api/package.json`, + JSON.stringify(apiInfo, null, 2), + "utf8", + ); + execute(location)("npm run build:api"); + execute(location)("npm run build:swagger"); + cp.execSync( + tag === "tgz" + ? "npm pack" + : `npm publish --tag ${tag} --access public`, + { + stdio: "ignore", + cwd: `${location}/packages/api` + }, + ); console.log(""); }; @@ -76,14 +136,7 @@ const publish = (tag) => { throw new Error(`latest tag can only be used for non-dev versions.`); // DO DEPLOY - for (const pack of [ - "fake-iamport-server", - "fake-toss-payments-server", - "iamport-server-api", - "toss-payments-server-api", - "payment-backend", - "payment-api", - ]) + for (const pack of PACKAGES) deploy(tag)(version)(pack); }; diff --git a/package.json b/package.json index e855663..9ad15e9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@samchon/payments", - "version": "8.0.2", + "version": "8.1.0", "description": "Collection of Payment system of Samchon", "scripts": { "package:latest": "node deploy latest", diff --git a/packages/fake-iamport-server/README.md b/packages/fake-iamport-server/README.md index 038c3b5..a519d00 100644 --- a/packages/fake-iamport-server/README.md +++ b/packages/fake-iamport-server/README.md @@ -12,7 +12,7 @@ 참고로 [`nestia`](https://github.com/samchon/nestia) 는 SDK 뿐 아니라 Swagger 또한 빌드할 수 있는데, 이 또한 `fake-iamport-server` 의 소스코드 및 DTO 를 컴파일러 수준에서 분석하여 만들어지는 것인지라, 그 퀄리티가 상당하다. 어쩌면 아임포트가 공식 제공하는 개발자 가이드 문서보다, `fake-iamport-server` 로 생성한 Swagger 가 더 개발자 친화적이고 일목요연할지도? - 서버 주소: http://localhost:10851 - - **Swagger Editor**: [packages/iamport-server-api/swagger.json](https://stackblitz.com/edit/5jpnps?file=README.md,test%2Fstart.ts&startScript=swagger&startScript=hello) + - **Swagger Editor**: [packages/fake-iamport-server/packages/api/swagger.json](https://stackblitz.com/edit/5jpnps?file=README.md,test%2Fstart.ts&startScript=swagger&startScript=hello) - 자료 구조: [src/api/structures/IIamportPayment.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/src/api/structures/IIamportPayment.ts) - API 함수: [src/api/functional/payments/index.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/src/api/functional/payments/index.ts) - 예제 코드 diff --git a/packages/fake-iamport-server/nestia.config.ts b/packages/fake-iamport-server/nestia.config.ts index c1456e1..fbdb037 100644 --- a/packages/fake-iamport-server/nestia.config.ts +++ b/packages/fake-iamport-server/nestia.config.ts @@ -7,9 +7,9 @@ import { FakeIamportModule } from "./src/FakeIamportModule"; const NESTIA_CONFIG: INestiaConfig = { input: () => NestFactory.create(FakeIamportModule, new FastifyAdapter()), output: "src/api", - distribute: "../iamport-server-api", + distribute: "packages/api", swagger: { - output: "../iamport-server-api/swagger.json", + output: "packages/api/swagger.json", info: { title: "Iamport API", description: diff --git a/packages/fake-iamport-server/package.json b/packages/fake-iamport-server/package.json index 8e4b1fa..7f493f4 100644 --- a/packages/fake-iamport-server/package.json +++ b/packages/fake-iamport-server/package.json @@ -1,14 +1,15 @@ { "name": "fake-iamport-server", - "version": "8.0.2", + "version": "8.1.0", "description": "Fake iamport server for testing", "main": "lib/index.js", + "module": "lib/index.mjs", "typings": "lib/index.d.ts", "scripts": { "----------------------------------------------": "", "build": "npm run build:sdk && npm run build:main && npm run build:test", - "build:api": "rimraf packages/api/lib && nestia sdk && npx copyfiles README.md packages/api && tsc -p packages/api/tsconfig.json", - "build:main": "rimraf lib && tsc", + "build:api": "rimraf packages/api/lib && nestia sdk && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js", + "build:main": "rimraf lib && tsc && rollup -c", "build:sdk": "rimraf src/api/functional && nestia sdk", "build:swagger": "nestia swagger", "build:test": "rimraf bin && tsc -p test/tsconfig.json", @@ -16,7 +17,6 @@ "eslint": "eslint src && eslint --config .eslintrc.test.cjs test", "eslint:fix": "eslint --fix src && eslint --fix --config .eslintrc.test.cjs test", "------------------------------------------------": "", - "package:api": "npm run build:swagger && npm run build:api && cd packages/api && npm publish", "package:latest": "npm run build && npm run test && npm publish", "package:next": "npm run package:latest -- --tag next", "prepare": "ts-patch install && typia patch", @@ -38,40 +38,43 @@ }, "homepage": "https://github.com/samchon/fake-iamport-server", "devDependencies": { - "@nestia/sdk": "^3.3.2", + "@nestia/sdk": "^3.7.0", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6", "@types/atob": "^2.1.2", "@types/btoa": "^1.2.3", "@types/cli": "^0.11.19", "@types/node": "^20.14.9", - "@types/uuid": "^9.0.1", + "@types/uuid": "^10.0.0", "@typescript-eslint/eslint-plugin": "^5.26.0", "@typescript-eslint/parser": "^5.26.0", + "chalk": "^4.1.2", "cli": "^1.0.1", "copyfiles": "^2.4.1", "nestia": "^5.1.2", "pm2": "^4.5.6", "rimraf": "^3.0.2", + "rollup": "^4.18.1", "sloc": "^0.2.1", "ts-node": "^10.9.1", "ts-patch": "^3.2.1", "typescript": "^5.5.2" }, "dependencies": { - "@nestia/core": "^3.3.2", - "@nestia/e2e": "^0.6.0", - "@nestia/fetcher": "^3.3.2", - "@nestjs/common": "^10.2.8", - "@nestjs/core": "^10.2.8", - "@nestjs/platform-fastify": "^10.2.8", + "@nestia/core": "^3.7.0", + "@nestia/e2e": "^0.7.0", + "@nestia/fetcher": "^3.7.0", + "@nestjs/common": "^10.3.10", + "@nestjs/core": "^10.3.10", + "@nestjs/platform-fastify": "^10.3.10", "atob": "^2.1.2", "btoa": "^1.2.1", - "fastify": "^4.24.3", "serialize-error": "^4.1.0", "source-map-support": "^0.5.19", "tstl": "^3.0.0", "typescript-transform-paths": "^3.4.6", - "typia": "^6.3.1", - "uuid": "^9.0.0" + "typia": "^6.5.0", + "uuid": "^10.0.0" }, "keywords": [ "toss", diff --git a/packages/iamport-server-api/README.md b/packages/fake-iamport-server/packages/api/README.md similarity index 96% rename from packages/iamport-server-api/README.md rename to packages/fake-iamport-server/packages/api/README.md index 209c332..3f90eb3 100644 --- a/packages/iamport-server-api/README.md +++ b/packages/fake-iamport-server/packages/api/README.md @@ -12,7 +12,7 @@ npm install --save iamport-server-api 고로 아임포트와 연동하는 TypeScript 기반 백엔드 서버를 개발함에 있어, 가짜 아임포트 서버 [`fake-iamport-server`](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server) 는 직접 이용치 않더라도, 실제 아임포트 서버와의 연동을 위하여, 본 SDK 라이브러리만큼은 반드시 설치하기를 권장하는 바이다. - - **Swagger Editor**: [packages/iamport-server-api/swagger.json](https://stackblitz.com/edit/5jpnps?file=README.md,test%2Fstart.ts&startScript=swagger&startScript=hello) + - **Swagger Editor**: [packages/fake-iamport-server/packages/api/swagger.json](https://stackblitz.com/edit/5jpnps?file=README.md,test%2Fstart.ts&startScript=swagger&startScript=hello) - 자료 구조: [src/api/structures/IIamportPayment.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/src/api/structures/IIamportPayment.ts) - API 함수: [src/api/functional/payments/index.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/src/api/functional/payments/index.ts) - 예제 코드 diff --git a/packages/fake-iamport-server/packages/api/package.json b/packages/fake-iamport-server/packages/api/package.json new file mode 100644 index 0000000..54af684 --- /dev/null +++ b/packages/fake-iamport-server/packages/api/package.json @@ -0,0 +1,29 @@ +{ + "name": "iamport-server-api", + "version": "8.1.0", + "description": "API for Iamport Server", + "main": "lib/index.js", + "module": "lib/index.mjs", + "typings": "lib/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/samchon/payments" + }, + "author": "Jeongho Nam", + "license": "MIT", + "bugs": { + "url": "https://github.com/samchon/payments/issues" + }, + "homepage": "https://github.com/samchon/payments", + "files": [ + "lib", + "package.json", + "swagger.json", + "README.md" + ], + "dependencies": { + "@nestia/fetcher": "^3.7.0", + "tstl": "^3.0.0", + "typia": "^6.5.0" + } +} \ No newline at end of file diff --git a/packages/fake-iamport-server/packages/api/rollup.config.js b/packages/fake-iamport-server/packages/api/rollup.config.js new file mode 100644 index 0000000..0908021 --- /dev/null +++ b/packages/fake-iamport-server/packages/api/rollup.config.js @@ -0,0 +1,29 @@ +const typescript = require("@rollup/plugin-typescript"); +const terser = require("@rollup/plugin-terser"); + +module.exports = { + input: `${__dirname}/../../src/api/index.ts`, + output: { + dir: `${__dirname}/lib`, + format: "esm", + entryFileNames: "[name].mjs", + sourcemap: true, + }, + plugins: [ + typescript({ + tsconfig: `${__dirname}/tsconfig.json`, + module: "ESNext", + target: "ESNext", + }), + terser({ + format: { + comments: "some", + beautify: true, + ecma: "2020", + }, + compress: false, + mangle: false, + module: true, + }), + ], +}; diff --git a/packages/iamport-server-api/swagger.json b/packages/fake-iamport-server/packages/api/swagger.json similarity index 98% rename from packages/iamport-server-api/swagger.json rename to packages/fake-iamport-server/packages/api/swagger.json index 49ad618..92f8909 100644 --- a/packages/iamport-server-api/swagger.json +++ b/packages/fake-iamport-server/packages/api/swagger.json @@ -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": "8.0.2", + "version": "8.1.0", "license": { "name": "MIT" } @@ -29,8 +29,8 @@ "schema": { "type": "string" }, - "description": "고객 (간편 결제 카드) 식별자 키", - "required": true + "required": true, + "description": " 고객 (간편 결제 카드) 식별자 키" } ], "responses": { @@ -62,8 +62,8 @@ "schema": { "type": "string" }, - "description": "고객 (간편 결제 카드) 식별자 키", - "required": true + "required": true, + "description": " 고객 (간편 결제 카드) 식별자 키" } ], "requestBody": { @@ -106,8 +106,8 @@ "schema": { "type": "string" }, - "description": "고객 (간편 결제 카드) 식별자 키", - "required": true + "required": true, + "description": " 고객 (간편 결제 카드) 식별자 키" } ], "responses": { @@ -213,8 +213,8 @@ "schema": { "type": "string" }, - "description": "대상 본인인증 정보의 ", - "required": true + "required": true, + "description": " 대상 본인인증 정보의 {@link IIamportCertification.imp_uid}" } ], "responses": { @@ -246,8 +246,8 @@ "schema": { "type": "string" }, - "description": "대상 본인인증 정보의 ", - "required": true + "required": true, + "description": " 대상 본인인증 정보의 {@link IIamportCertification.imp_uid}" } ], "responses": { @@ -317,8 +317,8 @@ "schema": { "type": "string" }, - "description": "대상 본인인증 정보의 ", - "required": true + "required": true, + "description": " 대상 본인인증 정보의 {@link IIamportCertification.imp_uid}" } ], "requestBody": { @@ -387,8 +387,8 @@ "schema": { "type": "string" }, - "description": "대상 결제의 ", - "required": true + "required": true, + "description": " 대상 결제의 {@link IIamportVBankPayment.imp_uid }" } ], "responses": { @@ -415,17 +415,20 @@ "schema": { "type": "string" }, - "description": "대상 결제 기록의 ", - "required": true + "required": true, + "description": " 대상 결제 기록의 {@link IIamportPayment.imp_uid}" }, { - "name": "query", + "name": "extension", "in": "query", "schema": { - "$ref": "#/components/schemas/IIamportPayment.IQuery" + "type": "boolean", + "title": "페이팔의 경우, 이 값을 `true` 로 할 것", + "description": "페이팔의 경우, 이 값을 `true` 로 할 것." }, - "description": "결제 수단이 페이팔인 경우에 사용", - "required": true + "required": false, + "title": "페이팔의 경우, 이 값을 `true` 로 할 것", + "description": "페이팔의 경우, 이 값을 `true` 로 할 것." } ], "responses": { @@ -495,8 +498,8 @@ "schema": { "type": "string" }, - "description": "귀속 결제의 ", - "required": true + "required": true, + "description": " 귀속 결제의 {@link IIamportPayment.imp_uid}" } ], "responses": { @@ -528,8 +531,8 @@ "schema": { "type": "string" }, - "description": "귀속 결제의 ", - "required": true + "required": true, + "description": " 귀속 결제의 {@link IIamportPayment.imp_uid}" } ], "requestBody": { @@ -572,8 +575,8 @@ "schema": { "type": "string" }, - "description": "귀속 결제의 ", - "required": true + "required": true, + "description": " 귀속 결제의 {@link IIamportPayment.imp_uid}" } ], "responses": { diff --git a/packages/fake-iamport-server/packages/api/tsconfig.json b/packages/fake-iamport-server/packages/api/tsconfig.json new file mode 100644 index 0000000..8b207e6 --- /dev/null +++ b/packages/fake-iamport-server/packages/api/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "target": "ES5", + "declaration": true, + "outDir": "lib", + "downlevelIteration": true, + "lib": [ + "DOM", + "ES2015", + ], + }, + "include": ["../../src/api"], + "exclude": ["node_modules"], +} \ No newline at end of file diff --git a/packages/fake-iamport-server/rollup.config.js b/packages/fake-iamport-server/rollup.config.js new file mode 100644 index 0000000..f948ecc --- /dev/null +++ b/packages/fake-iamport-server/rollup.config.js @@ -0,0 +1,29 @@ +const typescript = require("@rollup/plugin-typescript"); +const terser = require("@rollup/plugin-terser"); + +module.exports = { + input: "./src/index.ts", + output: { + dir: "lib", + format: "esm", + entryFileNames: "[name].mjs", + sourcemap: true, + }, + plugins: [ + typescript({ + tsconfig: "tsconfig.json", + module: "ES2020", + target: "ES2020", + }), + terser({ + format: { + comments: "some", + beautify: true, + ecma: "2020", + }, + compress: false, + mangle: false, + module: true, + }), + ], +}; diff --git a/packages/fake-iamport-server/src/api/utils/NestiaSimulator.ts b/packages/fake-iamport-server/src/api/utils/NestiaSimulator.ts deleted file mode 100644 index 085ff9f..0000000 --- a/packages/fake-iamport-server/src/api/utils/NestiaSimulator.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { HttpError } from "@nestia/fetcher"; - -import typia from "typia"; - -export namespace NestiaSimulator { - export interface IProps { - host: string; - path: string; - method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE"; - contentType: string; - } - - export const assert = (props: IProps) => { - return { - param: param(props), - query: query(props), - body: body(props), - }; - }; - const param = - (props: IProps) => - (name: string) => - (task: () => T): void => { - validate( - (exp) => `URL parameter "${name}" is not ${exp.expected} type.`, - )(props)(task); - }; - - const query = - (props: IProps) => - (task: () => T): void => - validate( - () => - "Request query parameters are not following the promised type.", - )(props)(task); - - const body = - (props: IProps) => - (task: () => T): void => - validate(() => "Request body is not following the promised type.")( - props, - )(task); - - const validate = - (message: (exp: typia.TypeGuardError) => string, path?: string) => - (props: IProps) => - (task: () => T): void => { - try { - task(); - } catch (exp) { - if (typia.is(exp)) - throw new HttpError( - props.method, - props.host + props.path, - 400, - { - "Content-Type": props.contentType, - }, - JSON.stringify({ - method: exp.method, - path: path ?? exp.path, - expected: exp.expected, - value: exp.value, - message: message(exp), - }), - ); - throw exp; - } - }; -} diff --git a/packages/fake-iamport-server/test/index.ts b/packages/fake-iamport-server/test/index.ts index edec2c3..d556e76 100644 --- a/packages/fake-iamport-server/test/index.ts +++ b/packages/fake-iamport-server/test/index.ts @@ -1,4 +1,5 @@ import { DynamicExecutor } from "@nestia/e2e"; +import chalk from "chalk"; import { IamportConnector } from "iamport-server-api"; import { FakeIamportBackend } from "../src/FakeIamportBackend"; @@ -28,8 +29,19 @@ async function main(): Promise { // DO TEST const report: DynamicExecutor.IReport = await DynamicExecutor.validate({ prefix: "test", + location: __dirname + "/features", parameters: () => [connector], - })(__dirname + "/features"); + onComplete: (exec) => { + const trace = (str: string) => + console.log(` - ${chalk.green(exec.name)}: ${str}`); + if (exec.error === null) { + const elapsed: number = + new Date(exec.completed_at).getTime() - + new Date(exec.started_at).getTime(); + trace(`${chalk.yellow(elapsed.toLocaleString())} ms`); + } else trace(chalk.red(exec.error.name)); + }, + }); // TERMINATE await backend.close(); diff --git a/packages/fake-toss-payments-server/README.md b/packages/fake-toss-payments-server/README.md index e8758a0..bf62777 100644 --- a/packages/fake-toss-payments-server/README.md +++ b/packages/fake-toss-payments-server/README.md @@ -12,7 +12,7 @@ 참고로 [`nestia`](https://github.com/samchon/nestia) 는 SDK 뿐 아니라 Swagger 또한 빌드할 수 있는데, 이 또한 `fake-toss-payments-server` 의 소스코드 및 DTO 를 컴파일러 수준에서 분석하여 만들어지는 것인지라, 그 퀄리티가 상당하다. 어쩌면 토스 페이먼츠가 공식 제공하는 개발자 가이드 문서보다, `fake-toss-payments-server` 로 생성한 Swagger 가 더 개발자 친화적이고 일목요연할지도? - 서버 주소: http://localhost:30771 - - **Swagger Editor**: [toss-payments-server-api/swagger.json](https://stackblitz.com/edit/kltfqh?file=README.md,test%2Fstart.ts&startScript=swagger&startScript=hello) + - **Swagger Editor**: [fake-toss-payments-server/packages/api/swagger.json](https://stackblitz.com/edit/kltfqh?file=README.md,test%2Fstart.ts&startScript=swagger&startScript=hello) - 자료 구조: [src/api/structures/ITossBilling.ts](https://github.com/samchon/payments/tree/master/packages/fake-toss-payments-server/src/api/structures/ITossBilling.ts) - API 함수: [src/api/functional/v1/payments/index.ts](https://github.com/samchon/payments/tree/master/packages/fake-toss-payments-server/src/api/functional/v1/payments/index.ts) - 예제 코드 @@ -149,7 +149,7 @@ npm install --save toss-payments-server-api 참고로 [`nestia`](https://github.com/samchon/nestia) 는 SDK 뿐 아니라 Swagger 또한 빌드할 수 있는데, 이 또한 `fake-toss-payments-server` 의 소스코드 및 DTO 를 컴파일러 수준에서 분석하여 만들어지는 것인지라, 그 퀄리티가 상당하다. 어쩌면 토스 페이먼츠가 공식 제공하는 개발자 가이드 문서보다, `fake-toss-payments-server` 로 생성한 Swagger 가 더 개발자 친화적이고 일목요연할지도? - - **Swagger Editor**: [toss-payments-server-api/swagger.json](https://stackblitz.com/edit/kltfqh?file=README.md,test%2Fstart.ts&startScript=swagger&startScript=hello) + - **Swagger Editor**: [fake-toss-payments-server/packages/api/swagger.json](https://stackblitz.com/edit/kltfqh?file=README.md,test%2Fstart.ts&startScript=swagger&startScript=hello) - 자료 구조: [src/api/structures/ITossBilling.ts](https://github.com/samchon/payments/tree/master/packages/fake-toss-payments-server/src/api/structures/ITossBilling.ts) - API 함수: [src/api/functional/payments/index.ts](https://github.com/samchon/payments/tree/master/packages/fake-toss-payments-server/src/api/functional/payments/index.ts) - 예제 코드 diff --git a/packages/fake-toss-payments-server/nestia.config.ts b/packages/fake-toss-payments-server/nestia.config.ts index 3d5e61a..28023aa 100644 --- a/packages/fake-toss-payments-server/nestia.config.ts +++ b/packages/fake-toss-payments-server/nestia.config.ts @@ -7,9 +7,9 @@ import { FakeTossModule } from "./src/FakeTossModule"; const NESTIA_CONFIG: INestiaConfig = { input: () => NestFactory.create(FakeTossModule, new FastifyAdapter()), output: "src/api", - distribute: "../toss-payments-server-api", + distribute: "packages/api", swagger: { - output: "../toss-payments-server-api/swagger.json", + output: "packages/api/swagger.json", info: { title: "Toss Payments API", description: diff --git a/packages/fake-toss-payments-server/package.json b/packages/fake-toss-payments-server/package.json index 09d46ff..ece9c94 100644 --- a/packages/fake-toss-payments-server/package.json +++ b/packages/fake-toss-payments-server/package.json @@ -1,16 +1,17 @@ { "name": "fake-toss-payments-server", - "version": "8.0.2", + "version": "8.1.0", "description": "Fake toss-payments server for testing", "main": "lib/index.js", + "module": "lib/index.mjs", "typings": "lib/index.d.ts", "scripts": { "----------------------------------------------": "", "build": "npm run build:sdk && npm run build:main && npm run build:test", - "build:api": "rimraf packages/api/lib && nestia sdk && npx copyfiles README.md packages/api && tsc -p packages/api/tsconfig.json", + "build:api": "rimraf packages/api/lib && nestia sdk && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js", "build:sdk": "rimraf src/api/functional && nestia sdk", "build:swagger": "nestia swagger", - "build:main": "rimraf lib && tsc", + "build:main": "rimraf lib && tsc && rollup -c", "build:test": "rimraf bin && tsc -p test/tsconfig.json", "dev": "npm run build:test -- --watch", "eslint": "eslint src && eslint --config .eslintrc.test.cjs test", @@ -38,20 +39,24 @@ }, "homepage": "https://github.com/samchon/fake-toss-payments-server", "devDependencies": { - "@nestia/e2e": "^0.6.0", - "@nestia/sdk": "^3.3.2", + "@nestia/e2e": "^0.7.0", + "@nestia/sdk": "^3.7.0", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6", "@types/atob": "^2.1.2", "@types/btoa": "^1.2.3", "@types/cli": "^0.11.19", "@types/node": "^20.14.9", - "@types/uuid": "^9.0.1", + "@types/uuid": "^10.0.0", "@typescript-eslint/eslint-plugin": "^5.26.0", "@typescript-eslint/parser": "^5.26.0", + "chalk": "^4.1.2", "cli": "^1.0.1", "copyfiles": "^2.4.1", "nestia": "^5.1.2", "pm2": "^4.5.6", "rimraf": "^3.0.2", + "rollup": "^4.18.1", "sloc": "^0.2.1", "ts-node": "^10.9.1", "ts-patch": "^3.2.1", @@ -59,19 +64,18 @@ "typescript-transform-paths": "^3.4.6" }, "dependencies": { - "@nestia/core": "^3.3.2", - "@nestia/fetcher": "^3.3.2", - "@nestjs/common": "^10.2.8", - "@nestjs/core": "^10.2.8", - "@nestjs/platform-fastify": "^10.2.8", + "@nestia/core": "^3.7.0", + "@nestia/fetcher": "^3.7.0", + "@nestjs/common": "^10.3.10", + "@nestjs/core": "^10.3.10", + "@nestjs/platform-fastify": "^10.3.10", "atob": "^2.1.2", "btoa": "^1.2.1", - "fastify": "^4.24.3", "serialize-error": "^4.1.0", "source-map-support": "^0.5.19", "tstl": "^3.0.0", - "typia": "^6.3.1", - "uuid": "^9.0.0" + "typia": "^6.5.0", + "uuid": "^10.0.0" }, "keywords": [ "toss", diff --git a/packages/toss-payments-server-api/README.md b/packages/fake-toss-payments-server/packages/api/README.md similarity index 95% rename from packages/toss-payments-server-api/README.md rename to packages/fake-toss-payments-server/packages/api/README.md index da60492..5fa1a33 100644 --- a/packages/toss-payments-server-api/README.md +++ b/packages/fake-toss-payments-server/packages/api/README.md @@ -12,7 +12,7 @@ npm install --save toss-payments-server-api 고로 아임포트와 연동하는 TypeScript 기반 백엔드 서버를 개발함에 있어, 가짜 토스 페이먼츠 서버 [`fake-toss-payments-server`](https://github.com/samchon/payments/tree/master/packages/fake-toss-payments-server) 는 직접 이용치 않더라도, 실제 토스 페이먼츠 서버와의 연동을 위하여, 본 SDK 라이브러리만큼은 반드시 설치하기를 권장하는 바이다 - - **Swagger Editor**: [toss-payments-server-api/swagger.json](https://stackblitz.com/edit/kltfqh?file=README.md,test%2Fstart.ts&startScript=swagger&startScript=hello) + - **Swagger Editor**: [fake-toss-payments-server/packages/api/swagger.json](https://stackblitz.com/edit/kltfqh?file=README.md,test%2Fstart.ts&startScript=swagger&startScript=hello) - 자료 구조: [src/api/structures/ITossBilling.ts](https://github.com/samchon/payments/tree/master/packages/fake-toss-payments-server/src/api/structures/ITossBilling.ts) - API 함수: [src/api/functional/v1/payments/index.ts](https://github.com/samchon/payments/tree/master/packages/fake-toss-payments-server/src/api/functional/v1/payments/index.ts) - 예제 코드 diff --git a/packages/toss-payments-server-api/package.json b/packages/fake-toss-payments-server/packages/api/package.json similarity index 79% rename from packages/toss-payments-server-api/package.json rename to packages/fake-toss-payments-server/packages/api/package.json index 52828b7..9429a61 100644 --- a/packages/toss-payments-server-api/package.json +++ b/packages/fake-toss-payments-server/packages/api/package.json @@ -1,11 +1,11 @@ { "name": "toss-payments-server-api", - "version": "8.0.2", + "version": "8.1.0", "description": "API for Toss Payments Server", "main": "lib/index.js", "typings": "lib/index.d.ts", "scripts": { - "build": "npm run build:sdk && npm run compile", + "build": "npm run build:sdk && npm run compile && rollup -c", "build:sdk": "rimraf ../fake-toss-payments-server/src/api/functional && cd ../fake-toss-payments-server && npx nestia sdk && cd ../toss-payments-server-api", "compile": "rimraf lib && tsc", "deploy": "npm run build && npm publish", @@ -28,13 +28,16 @@ "README.md" ], "devDependencies": { + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6", "rimraf": "^5.0.1", + "rollup": "^4.18.1", "ts-node": "^10.9.1", "ts-patch": "^3.2.1", "typescript": "^5.5.2" }, "dependencies": { - "@nestia/fetcher": "^3.3.2", - "typia": "^6.3.1" + "@nestia/fetcher": "^3.7.0", + "typia": "^6.5.0" } } \ No newline at end of file diff --git a/packages/fake-toss-payments-server/packages/api/rollup.config.js b/packages/fake-toss-payments-server/packages/api/rollup.config.js new file mode 100644 index 0000000..0908021 --- /dev/null +++ b/packages/fake-toss-payments-server/packages/api/rollup.config.js @@ -0,0 +1,29 @@ +const typescript = require("@rollup/plugin-typescript"); +const terser = require("@rollup/plugin-terser"); + +module.exports = { + input: `${__dirname}/../../src/api/index.ts`, + output: { + dir: `${__dirname}/lib`, + format: "esm", + entryFileNames: "[name].mjs", + sourcemap: true, + }, + plugins: [ + typescript({ + tsconfig: `${__dirname}/tsconfig.json`, + module: "ESNext", + target: "ESNext", + }), + terser({ + format: { + comments: "some", + beautify: true, + ecma: "2020", + }, + compress: false, + mangle: false, + module: true, + }), + ], +}; diff --git a/packages/toss-payments-server-api/swagger.json b/packages/fake-toss-payments-server/packages/api/swagger.json similarity index 99% rename from packages/toss-payments-server-api/swagger.json rename to packages/fake-toss-payments-server/packages/api/swagger.json index 49cc357..97e4c82 100644 --- a/packages/toss-payments-server-api/swagger.json +++ b/packages/fake-toss-payments-server/packages/api/swagger.json @@ -13,7 +13,7 @@ "info": { "title": "Toss Payments API", "description": "Built by [fake-toss-payments-server](https://github.com/samchon/payments/tree/master/packages/toss-payments-server-api) with [nestia](https://github.com/samchon/nestia)", - "version": "8.0.2", + "version": "8.1.0", "license": { "name": "MIT" } @@ -65,8 +65,8 @@ "schema": { "type": "string" }, - "description": "대상 정보의 ", - "required": true + "required": true, + "description": " 대상 정보의 {@link ITossBilling.billingKey}" } ], "requestBody": { @@ -111,8 +111,8 @@ "schema": { "type": "string" }, - "description": "간편 결제에 등록한 수단의 ", - "required": true + "required": true, + "description": " 간편 결제에 등록한 수단의 {@link ITossBilling.billingKey}" } ], "requestBody": { @@ -193,8 +193,8 @@ "schema": { "type": "string" }, - "description": "현금 영수증의 ", - "required": true + "required": true, + "description": " 현금 영수증의 {@link ITossCashReceipt.receiptKey}" } ], "requestBody": { @@ -263,8 +263,8 @@ "schema": { "type": "string" }, - "description": "대상 가상 계좌 결제 정보의 ", - "required": true + "required": true, + "description": " 대상 가상 계좌 결제 정보의 {@link ITossPayment.paymentKey}" } ], "responses": { @@ -298,8 +298,8 @@ "schema": { "type": "string" }, - "description": "결제 정보의 ", - "required": true + "required": true, + "description": " 결제 정보의 {@link ITossPayment.paymentKey}" } ], "responses": { @@ -326,8 +326,8 @@ "schema": { "type": "string" }, - "description": "대상 결제의 ", - "required": true + "required": true, + "description": " 대상 결제의 {@link ITossPayment.paymentKey}" } ], "requestBody": { @@ -408,8 +408,8 @@ "schema": { "type": "string" }, - "description": "결제 정보의 ", - "required": true + "required": true, + "description": " 결제 정보의 {@link ITossPayment.paymentKey}" } ], "requestBody": { diff --git a/packages/fake-toss-payments-server/packages/api/tsconfig.json b/packages/fake-toss-payments-server/packages/api/tsconfig.json new file mode 100644 index 0000000..8b207e6 --- /dev/null +++ b/packages/fake-toss-payments-server/packages/api/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "target": "ES5", + "declaration": true, + "outDir": "lib", + "downlevelIteration": true, + "lib": [ + "DOM", + "ES2015", + ], + }, + "include": ["../../src/api"], + "exclude": ["node_modules"], +} \ No newline at end of file diff --git a/packages/fake-toss-payments-server/rollup.config.js b/packages/fake-toss-payments-server/rollup.config.js new file mode 100644 index 0000000..f948ecc --- /dev/null +++ b/packages/fake-toss-payments-server/rollup.config.js @@ -0,0 +1,29 @@ +const typescript = require("@rollup/plugin-typescript"); +const terser = require("@rollup/plugin-terser"); + +module.exports = { + input: "./src/index.ts", + output: { + dir: "lib", + format: "esm", + entryFileNames: "[name].mjs", + sourcemap: true, + }, + plugins: [ + typescript({ + tsconfig: "tsconfig.json", + module: "ES2020", + target: "ES2020", + }), + terser({ + format: { + comments: "some", + beautify: true, + ecma: "2020", + }, + compress: false, + mangle: false, + module: true, + }), + ], +}; diff --git a/packages/fake-toss-payments-server/test/index.ts b/packages/fake-toss-payments-server/test/index.ts index 3348c16..34efe58 100644 --- a/packages/fake-toss-payments-server/test/index.ts +++ b/packages/fake-toss-payments-server/test/index.ts @@ -1,4 +1,5 @@ import { DynamicExecutor } from "@nestia/e2e"; +import chalk from "chalk"; import { FakeTossBackend } from "../src/FakeTossBackend"; import { FakeTossConfiguration } from "../src/FakeTossConfiguration"; @@ -18,8 +19,19 @@ async function main(): Promise { const report: DynamicExecutor.IReport = await DynamicExecutor.validate({ extension: __filename.substr(-2), prefix: "test", + location: __dirname + "/features", parameters: () => [connection], - })(__dirname + "/features"); + onComplete: (exec) => { + const trace = (str: string) => + console.log(` - ${chalk.green(exec.name)}: ${str}`); + if (exec.error === null) { + const elapsed: number = + new Date(exec.completed_at).getTime() - + new Date(exec.started_at).getTime(); + trace(`${chalk.yellow(elapsed.toLocaleString())} ms`); + } else trace(chalk.red(exec.error.name)); + }, + }); // TERMINATE await backend.close(); diff --git a/packages/iamport-server-api/package.json b/packages/iamport-server-api/package.json deleted file mode 100644 index d35d17f..0000000 --- a/packages/iamport-server-api/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "iamport-server-api", - "version": "8.0.2", - "description": "API for Iamport Server", - "main": "lib/index.js", - "typings": "lib/index.d.ts", - "scripts": { - "build": "npm run build:sdk && npm run compile", - "build:sdk": "rimraf ../fake-iamport-server/src/api/functional && cd ../fake-iamport-server && npx nestia sdk && cd ../iamport-server-api", - "compile": "rimraf lib && tsc", - "deploy": "npm run build && npm publish", - "prepare": "ts-patch install && typia patch" - }, - "repository": { - "type": "git", - "url": "https://github.com/samchon/payments" - }, - "author": "Jeongho Nam", - "license": "MIT", - "bugs": { - "url": "https://github.com/samchon/payments/issues" - }, - "homepage": "https://github.com/samchon/payments", - "files": [ - "lib", - "package.json", - "swagger.json", - "README.md" - ], - "devDependencies": { - "rimraf": "^5.0.1", - "ts-node": "^10.9.1", - "ts-patch": "^3.2.1", - "typescript": "^5.5.2" - }, - "dependencies": { - "@nestia/fetcher": "^3.3.2", - "typia": "^6.3.1" - } -} \ No newline at end of file diff --git a/packages/iamport-server-api/tsconfig.json b/packages/iamport-server-api/tsconfig.json deleted file mode 100644 index cff3499..0000000 --- a/packages/iamport-server-api/tsconfig.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - /* Language and Environment */ - "target": "ES5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - "lib": [ - "DOM", - "ES2020" - ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */// "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */// "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - /* Emit */ - "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */// "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - "sourceMap": true, /* Create source map files for emitted JavaScript files. */// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./lib", /* Specify an output folder for all emitted files. */// "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ - "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - "newLine": "lf", /* Set the newline character for emitting files. */// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. *//* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true, /* Skip type checking all .d.ts files. */ - "plugins": [ - { - "transform": "typia/lib/transform" - } - ], - "strictNullChecks": true - }, - "include": [ - "../fake-iamport-server/src/api" - ] -} \ No newline at end of file diff --git a/packages/payment-api/tsconfig.json b/packages/payment-api/tsconfig.json deleted file mode 100644 index 271e099..0000000 --- a/packages/payment-api/tsconfig.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - /* Language and Environment */ - "target": "ES5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - "lib": [ - "DOM", - "ES2020" - ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */// "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */// "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - /* Emit */ - "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */// "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - "sourceMap": true, /* Create source map files for emitted JavaScript files. */// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./lib", /* Specify an output folder for all emitted files. */// "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ - "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - "newLine": "lf", /* Set the newline character for emitting files. */// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. *//* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true, /* Skip type checking all .d.ts files. */ - "plugins": [ - { - "transform": "typia/lib/transform" - } - ], - "strictNullChecks": true - }, - "include": [ - "../payment-backend/src/api" - ] -} \ No newline at end of file diff --git a/packages/payment-backend/nestia.config.ts b/packages/payment-backend/nestia.config.ts index 49ecc13..12a6563 100644 --- a/packages/payment-backend/nestia.config.ts +++ b/packages/payment-backend/nestia.config.ts @@ -7,9 +7,9 @@ import { PaymentModule } from "./src/PaymentModule"; const NESTIA_CONFIG: INestiaConfig = { input: () => NestFactory.create(PaymentModule, new FastifyAdapter()), output: "src/api", - distribute: "../payment-api", + distribute: "packages/api", swagger: { - output: "../payment-api/swagger.json", + output: "packages/api/swagger.json", beautify: true, }, primitive: false, diff --git a/packages/payment-backend/package.json b/packages/payment-backend/package.json index acd72c3..e322fc3 100644 --- a/packages/payment-backend/package.json +++ b/packages/payment-backend/package.json @@ -1,15 +1,16 @@ { "name": "@samchon/payment-backend", - "version": "8.0.2", + "version": "8.1.0", "description": "Payment Backend Server", "main": "lib/index.js", + "module": "lib/index.mjs", "typings": "lib/index.d.ts", "scripts": { "test": "rimraf prisma/migrations && node bin/test", "------------------------BUILDS------------------------": "", "build": "npm run build:sdk && npm run build:main && npm run build:test", - "build:api": "rimraf packages/api/lib && nestia sdk && tsc -p packages/api/tsconfig.json", - "build:main": "rimraf lib && tsc", + "build:api": "rimraf packages/api/lib && nestia sdk && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js", + "build:main": "rimraf lib && tsc && rollup -c", "build:prisma": "prisma generate --schema=prisma/schema.prisma", "build:sdk": "rimraf src/api/functional && nestia sdk", "build:swagger": "nestia swagger", @@ -37,8 +38,8 @@ }, "homepage": "https://github.com/samchon/payments", "devDependencies": { - "@nestia/fetcher": "^3.3.2", - "@nestia/sdk": "^3.3.2", + "@nestia/fetcher": "^3.7.0", + "@nestia/sdk": "^3.7.0", "@types/atob": "^2.1.2", "@types/bcryptjs": "^2.4.4", "@types/btoa": "^1.2.3", @@ -50,15 +51,17 @@ "@types/uuid": "^8.3.0", "@typescript-eslint/eslint-plugin": "^5.26.0", "@typescript-eslint/parser": "^5.26.0", + "chalk": "^4.1.2", "cli": "^1.0.1", "copy-webpack-plugin": "^11.0.0", "copyfiles": "^2.4.1", - "iamport-server-api": "^8.0.2", + "iamport-server-api": "^8.1.0", "nestia": "^5.0.3", "pm2": "^4.5.6", "rimraf": "^3.0.2", + "rollup": "^4.18.1", "sloc": "^0.2.1", - "toss-payments-server-api": "^8.0.2", + "toss-payments-server-api": "^8.1.0", "ts-loader": "^9.5.0", "ts-node": "^10.9.1", "ts-patch": "^3.2.1", @@ -69,21 +72,22 @@ "write-file-webpack-plugin": "^4.5.1" }, "dependencies": { - "@nestia/core": "^3.3.2", - "@nestia/e2e": "^0.6.0", - "@nestjs/common": "^10.2.8", - "@nestjs/core": "^10.2.8", - "@nestjs/platform-fastify": "^10.2.8", + "@nestia/core": "^3.7.0", + "@nestia/e2e": "^0.7.0", + "@nestjs/common": "^10.3.10", + "@nestjs/core": "^10.3.10", + "@nestjs/platform-fastify": "^10.3.10", "@prisma/client": "^5.9.1", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6", "atob": "^2.1.2", "bcryptjs": "^2.4.3", "btoa": "^1.2.1", "commander": "10.0.0", "dotenv": "^16.3.1", "dotenv-expand": "^10.0.0", - "fake-iamport-server": "^8.0.2", - "fake-toss-payments-server": "^8.0.2", - "fastify": "^4.24.3", + "fake-iamport-server": "^8.1.0", + "fake-toss-payments-server": "^8.1.0", "git-last-commit": "^1.0.0", "inquirer": "^8.2.5", "prisma": "^5.9.1", @@ -91,8 +95,8 @@ "serialize-error": "^4.1.0", "source-map-support": "^0.5.19", "tstl": "^3.0.0", - "typia": "^6.3.1", - "uuid": "^9.0.1" + "typia": "^6.5.0", + "uuid": "^10.0.0" }, "files": [ "lib", diff --git a/packages/payment-api/README.md b/packages/payment-backend/packages/api/README.md similarity index 100% rename from packages/payment-api/README.md rename to packages/payment-backend/packages/api/README.md diff --git a/packages/payment-api/package.json b/packages/payment-backend/packages/api/package.json similarity index 72% rename from packages/payment-api/package.json rename to packages/payment-backend/packages/api/package.json index 9840876..65b1783 100644 --- a/packages/payment-api/package.json +++ b/packages/payment-backend/packages/api/package.json @@ -1,11 +1,12 @@ { "name": "@samchon/payment-api", - "version": "8.0.2", + "version": "8.1.0", "description": "API for Payment Backend", "main": "lib/index.js", + "module": "lib/index.mjs", "typings": "lib/index.d.ts", "scripts": { - "build": "npm run build:sdk && npm run compile", + "build": "npm run build:sdk && npm run compile && rollup -c", "build:sdk": "rimraf ../payment-backend/src/api/functional && cd ../payment-backend && npx nestia sdk && cd ../payment-api", "compile": "rimraf lib && tsc", "deploy": "npm run build && npm publish", @@ -28,16 +29,19 @@ "README.md" ], "devDependencies": { + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6", "@types/node": "^20.14.9", "rimraf": "^5.0.1", + "rollup": "^4.18.1", "ts-node": "^10.9.1", "ts-patch": "^3.2.1", "typescript": "^5.5.2" }, "dependencies": { - "@nestia/fetcher": "^3.3.2", - "iamport-server-api": "^8.0.2", - "toss-payments-server-api": "^8.0.2", - "typia": "^6.3.1" + "@nestia/fetcher": "^3.7.0", + "iamport-server-api": "^8.1.0", + "toss-payments-server-api": "^8.1.0", + "typia": "^6.5.0" } } \ No newline at end of file diff --git a/packages/payment-backend/packages/api/rollup.config.js b/packages/payment-backend/packages/api/rollup.config.js new file mode 100644 index 0000000..0908021 --- /dev/null +++ b/packages/payment-backend/packages/api/rollup.config.js @@ -0,0 +1,29 @@ +const typescript = require("@rollup/plugin-typescript"); +const terser = require("@rollup/plugin-terser"); + +module.exports = { + input: `${__dirname}/../../src/api/index.ts`, + output: { + dir: `${__dirname}/lib`, + format: "esm", + entryFileNames: "[name].mjs", + sourcemap: true, + }, + plugins: [ + typescript({ + tsconfig: `${__dirname}/tsconfig.json`, + module: "ESNext", + target: "ESNext", + }), + terser({ + format: { + comments: "some", + beautify: true, + ecma: "2020", + }, + compress: false, + mangle: false, + module: true, + }), + ], +}; diff --git a/packages/payment-api/swagger.json b/packages/payment-backend/packages/api/swagger.json similarity index 99% rename from packages/payment-api/swagger.json rename to packages/payment-backend/packages/api/swagger.json index 87f86ae..140765c 100644 --- a/packages/payment-api/swagger.json +++ b/packages/payment-backend/packages/api/swagger.json @@ -7,7 +7,7 @@ } ], "info": { - "version": "8.0.2", + "version": "8.1.0-dev.20240713-3", "title": "@samchon/payment-backend", "description": "Payment Backend Server", "license": { @@ -108,8 +108,8 @@ "type": "string", "format": "uuid" }, - "description": "Primary Key", - "required": true + "required": true, + "description": " Primary Key" } ], "requestBody": { @@ -251,8 +251,8 @@ "type": "string", "format": "uuid" }, - "description": "Primary Key", - "required": true + "required": true, + "description": " Primary Key" } ], "requestBody": { diff --git a/packages/payment-backend/packages/api/tsconfig.json b/packages/payment-backend/packages/api/tsconfig.json new file mode 100644 index 0000000..8b207e6 --- /dev/null +++ b/packages/payment-backend/packages/api/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "target": "ES5", + "declaration": true, + "outDir": "lib", + "downlevelIteration": true, + "lib": [ + "DOM", + "ES2015", + ], + }, + "include": ["../../src/api"], + "exclude": ["node_modules"], +} \ No newline at end of file diff --git a/packages/payment-backend/rollup.config.js b/packages/payment-backend/rollup.config.js new file mode 100644 index 0000000..f948ecc --- /dev/null +++ b/packages/payment-backend/rollup.config.js @@ -0,0 +1,29 @@ +const typescript = require("@rollup/plugin-typescript"); +const terser = require("@rollup/plugin-terser"); + +module.exports = { + input: "./src/index.ts", + output: { + dir: "lib", + format: "esm", + entryFileNames: "[name].mjs", + sourcemap: true, + }, + plugins: [ + typescript({ + tsconfig: "tsconfig.json", + module: "ES2020", + target: "ES2020", + }), + terser({ + format: { + comments: "some", + beautify: true, + ecma: "2020", + }, + compress: false, + mangle: false, + module: true, + }), + ], +}; diff --git a/packages/payment-backend/src/api/functional/payments/internal/index.ts b/packages/payment-backend/src/api/functional/payments/internal/index.ts index c38e357..b6d9302 100644 --- a/packages/payment-backend/src/api/functional/payments/internal/index.ts +++ b/packages/payment-backend/src/api/functional/payments/internal/index.ts @@ -10,9 +10,7 @@ import { EncryptedFetcher } from "@nestia/fetcher/lib/EncryptedFetcher"; import type { IPaymentWebhookHistory } from "../../../structures/payments/IPaymentWebhookHistory"; /** - * * @internal - * * @controller PaymentInternalController.webhook * @path POST /payments/internal/webhook * @nestia Generated by Nestia - https://github.com/samchon/nestia diff --git a/packages/payment-backend/src/api/functional/payments/webhooks/index.ts b/packages/payment-backend/src/api/functional/payments/webhooks/index.ts index ef750af..2086bcc 100644 --- a/packages/payment-backend/src/api/functional/payments/webhooks/index.ts +++ b/packages/payment-backend/src/api/functional/payments/webhooks/index.ts @@ -10,9 +10,7 @@ import type { IIamportPayment } from "iamport-server-api/lib/structures/IIamport import type { ITossPaymentWebhook } from "toss-payments-server-api/lib/structures/ITossPaymentWebhook"; /** - * * @danger - * * @controller PaymentWebhooksController.iamport * @path POST /payments/webhooks/iamport * @nestia Generated by Nestia - https://github.com/samchon/nestia @@ -58,9 +56,7 @@ export namespace iamport { } /** - * * @internal - * * @controller PaymentWebhooksController.toss * @path POST /payments/webhooks/toss * @nestia Generated by Nestia - https://github.com/samchon/nestia diff --git a/packages/payment-backend/test/index.ts b/packages/payment-backend/test/index.ts index e1a7ba5..07c2150 100644 --- a/packages/payment-backend/test/index.ts +++ b/packages/payment-backend/test/index.ts @@ -1,5 +1,6 @@ -import { DynamicExecutor, StopWatch } from "@nestia/e2e"; -import api from "@samchon/payment-api/lib/index"; +import { DynamicExecutor } from "@nestia/e2e"; +import api from "@samchon/payment-api"; +import chalk from "chalk"; import fs from "fs"; import { Singleton, randint } from "tstl"; import { sleep_for } from "tstl"; @@ -12,6 +13,7 @@ import { } from "../src"; import { ArgumentParser } from "../src/utils/ArgumentParser"; import { ErrorUtil } from "../src/utils/ErrorUtil"; +import { StopWatch } from "./internal/StopWatch"; interface IOptions { reset: boolean; @@ -88,6 +90,7 @@ async function main(): Promise { }; const report: DynamicExecutor.IReport = await DynamicExecutor.validate({ prefix: "test", + location: __dirname + "/features", parameters: () => [ { host: connection.host, @@ -99,7 +102,17 @@ async function main(): Promise { (options.include ?? []).some((str) => func.includes(str))) && (!options.exclude?.length || (options.exclude ?? []).every((str) => !func.includes(str))), - })(__dirname + "/features"); + onComplete: (exec) => { + const trace = (str: string) => + console.log(` - ${chalk.green(exec.name)}: ${str}`); + if (exec.error === null) { + const elapsed: number = + new Date(exec.completed_at).getTime() - + new Date(exec.started_at).getTime(); + trace(`${chalk.yellow(elapsed.toLocaleString())} ms`); + } else trace(chalk.red(exec.error.name)); + }, + }); // TERMINATE await sleep_for(2500); // WAIT FOR BACKGROUND EVENTS diff --git a/packages/payment-backend/test/internal/StopWatch.ts b/packages/payment-backend/test/internal/StopWatch.ts new file mode 100644 index 0000000..231b217 --- /dev/null +++ b/packages/payment-backend/test/internal/StopWatch.ts @@ -0,0 +1,19 @@ +export namespace StopWatch { + export type Task = () => Promise; + + export const measure = async (task: Task): Promise<[T, number]> => { + const time: number = Date.now(); + const output: T = await task(); + return [output, Date.now() - time]; + }; + + export const trace = + (title: string) => + async (task: Task): Promise<[T, number]> => { + process.stdout.write(` - ${title}: `); + const res: [T, number] = await measure(task); + + console.log(`${res[1].toLocaleString()} ms`); + return res; + }; +} diff --git a/packages/payment-backend/test/webpack.ts b/packages/payment-backend/test/webpack.ts index 85733a7..45329eb 100644 --- a/packages/payment-backend/test/webpack.ts +++ b/packages/payment-backend/test/webpack.ts @@ -1,5 +1,6 @@ import { DynamicExecutor } from "@nestia/e2e"; import api from "@samchon/payment-api/lib/index"; +import chalk from "chalk"; import fs from "fs"; import { Singleton, randint } from "tstl"; import { sleep_for } from "tstl"; @@ -51,13 +52,24 @@ async function main(): Promise { }; const report: DynamicExecutor.IReport = await DynamicExecutor.validate({ prefix: "test", + location: __dirname + "/features", parameters: () => [ { host: connection.host, encryption: connection.encryption, }, ], - })(__dirname + "/features"); + onComplete: (exec) => { + const trace = (str: string) => + console.log(` - ${chalk.green(exec.name)}: ${str}`); + if (exec.error === null) { + const elapsed: number = + new Date(exec.completed_at).getTime() - + new Date(exec.started_at).getTime(); + trace(`${chalk.yellow(elapsed.toLocaleString())} ms`); + } else trace(chalk.red(exec.error.name)); + }, + }); // TERMINATE await sleep_for(2500); // WAIT FOR BACKGROUND EVENTS diff --git a/packages/toss-payments-server-api/tsconfig.json b/packages/toss-payments-server-api/tsconfig.json deleted file mode 100644 index 7e8fe8c..0000000 --- a/packages/toss-payments-server-api/tsconfig.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - /* Language and Environment */ - "target": "ES5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - "lib": [ - "DOM", - "ES2020" - ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */// "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */// "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - /* Emit */ - "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */// "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - "sourceMap": true, /* Create source map files for emitted JavaScript files. */// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./lib", /* Specify an output folder for all emitted files. */// "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ - "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - "newLine": "lf", /* Set the newline character for emitting files. */// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. *//* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true, /* Skip type checking all .d.ts files. */ - "plugins": [ - { - "transform": "typia/lib/transform" - } - ], - "strictNullChecks": true - }, - "include": [ - "../fake-toss-payments-server/src/api" - ] -} \ No newline at end of file From f8767961b941651430e4e5fc9058c6a192eaa909 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Sun, 14 Jul 2024 02:51:40 +0900 Subject: [PATCH 2/2] Upload omitted swagger file --- packages/payment-backend/packages/api/swagger.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/payment-backend/packages/api/swagger.json b/packages/payment-backend/packages/api/swagger.json index 140765c..ab7aeef 100644 --- a/packages/payment-backend/packages/api/swagger.json +++ b/packages/payment-backend/packages/api/swagger.json @@ -7,7 +7,7 @@ } ], "info": { - "version": "8.1.0-dev.20240713-3", + "version": "8.1.0", "title": "@samchon/payment-backend", "description": "Payment Backend Server", "license": {