Skip to content

Commit

Permalink
Upgrade .env file to be compatible with other projects.
Browse files Browse the repository at this point in the history
To make `payment-backend` with compatible with other projects, added prefix `PAYMENT_` words on the `.env` file.
  • Loading branch information
samchon committed Oct 30, 2023
1 parent 8670275 commit 4038bcc
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 104 deletions.
11 changes: 6 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": "5.0.0",
"version": "5.0.1",
"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.3.0",
"@nestia/sdk": "^2.3.4",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"@types/atob": "^2.1.2",
"@types/btoa": "^1.2.3",
Expand All @@ -60,13 +60,14 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@nestia/core": "^2.3.0",
"@nestia/core": "^2.3.4",
"@nestia/e2e": "^0.3.6",
"@nestia/fetcher": "^2.3.0",
"@nestia/fetcher": "^2.3.4",
"serialize-error": "^4.1.0",
"source-map-support": "^0.5.19",
"tstl": "^2.5.13",
"typescript-transform-paths": "^3.4.6",
"typia": "^5.2.3",
"typia": "^5.2.4",
"uuid": "^9.0.0"
},
"keywords": [
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": "5.0.0",
"version": "5.0.1",
"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.3.0",
"@nestia/sdk": "^2.3.4",
"@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.3.0",
"@nestia/core": "^2.3.4",
"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.3",
"typia": "^5.2.4",
"uuid": "^9.0.0"
},
"keywords": [
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": "5.0.0",
"version": "5.0.1",
"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.3.0",
"typia": "^5.2.3"
"@nestia/fetcher": "^2.3.4",
"typia": "^5.2.4"
}
}
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": "5.0.0",
"version": "5.0.1",
"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": "5.0.0",
"version": "5.0.1",
"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.3.0",
"iamport-server-api": "^5.0.0",
"toss-payments-server-api": "^5.0.0",
"typia": "^5.2.3"
"@nestia/fetcher": "^2.3.4",
"iamport-server-api": "^5.0.1",
"toss-payments-server-api": "^5.0.1",
"typia": "^5.2.4"
}
}
2 changes: 1 addition & 1 deletion packages/payment-api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "5.0.0",
"version": "5.0.1",
"title": "@samchon/payment-backend",
"description": "Payment Backend Server",
"license": {
Expand Down
50 changes: 27 additions & 23 deletions packages/payment-backend/.env
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
MODE=local
API_PORT=37821
UPDATOR_PORT=37820
SYSTEM_PASSWORD=samchon
# BASIC SERVER INFO
PAYMENT_MODE=local
PAYMENT_API_PORT=37821
PAYMENT_UPDATOR_PORT=37820
PAYMENT_SYSTEM_PASSWORD=samchon

POSTGRES_HOST=127.0.0.1
POSTGRES_PORT=5432
POSTGRES_DATABASE=payments
POSTGRES_SCHEMA=payments
POSTGRES_USERNAME=samchon
POSTGRES_USERNAME_READONLY=samchon_r
POSTGRES_PASSWORD=samchon
POSTGRES_URL=postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}?schema=${POSTGRES_SCHEMA}
# DATABASE
PAYMENT_POSTGRES_HOST=127.0.0.1
PAYMENT_POSTGRES_PORT=5432
PAYMENT_POSTGRES_DATABASE=payments
PAYMENT_POSTGRES_SCHEMA=payments
PAYMENT_POSTGRES_USERNAME=samchon
PAYMENT_POSTGRES_USERNAME_READONLY=samchon_r
PAYMENT_POSTGRES_PASSWORD=samchon
PAYMENT_POSTGRES_URL=postgresql://${PAYMENT_POSTGRES_USERNAME}:${PAYMENT_POSTGRES_PASSWORD}@${PAYMENT_POSTGRES_HOST}:${PAYMENT_POSTGRES_PORT}/${PAYMENT_POSTGRES_DATABASE}?schema=${PAYMENT_POSTGRES_SCHEMA}

API_ENCRYPTION_KEY=MCKOxv9B23r7EatArCFcBP03nfaS03T8
API_ENCRYPTION_IV=9haeYD1tIf4v8xs7
DB_HISTORY_ENCRYPTION_KEY=MTlsOESZ6geZTjeaubOdR71tobe0KqE7
DB_HISTORY_ENCRYPTION_IV=7BqAGp1HPY9Ox66w
DB_RESERVATION_ENCRYPTION_KEY=0OrB5XVgkYpoybWeGIUkattMb4lTLQgz
DB_RESERVATION_ENCRYPTION_IV=ESgYCYV10Iy6qd1y
DB_CANCEL_HISTORY_ENCRYPTION_KEY=aU3y0PTXraB2SEYj1ACwtTYKxiYBvH4g
DB_CANCEL_HISTORY_ENCRYPTION_IV=fro2JXImhmbDtDNx
# ENCRYPTIONS
PAYMENT_CONNECTION_ENCRYPTION_KEY=MCKOxv9B23r7EatArCFcBP03nfaS03T8
PAYMENT_CONNECTION_ENCRYPTION_IV=9haeYD1tIf4v8xs7
PAYMENT_HISTORY_ENCRYPTION_KEY=MTlsOESZ6geZTjeaubOdR71tobe0KqE7
PAYMENT_HISTORY_ENCRYPTION_IV=7BqAGp1HPY9Ox66w
PAYMENT_RESERVATION_ENCRYPTION_KEY=0OrB5XVgkYpoybWeGIUkattMb4lTLQgz
PAYMENT_RESERVATION_ENCRYPTION_IV=ESgYCYV10Iy6qd1y
PAYMENT_CANCEL_HISTORY_ENCRYPTION_KEY=aU3y0PTXraB2SEYj1ACwtTYKxiYBvH4g
PAYMENT_CANCEL_HISTORY_ENCRYPTION_IV=fro2JXImhmbDtDNx

IAMPORT_KEY=aaaaaa
IAMPORT_SECRET=bbbbb
TOSS_PAYMENTS_SECRET=test_ak_ZORzdMaqN3wQd5k6ygr5AkYXQGwy
# VENDORS
PAYMENT_IAMPORT_KEY=aaaaaa
PAYMENT_IAMPORT_SECRET=bbbbb
PAYMENT_TOSS_PAYMENTS_SECRET=test_ak_ZORzdMaqN3wQd5k6ygr5AkYXQGwy
19 changes: 10 additions & 9 deletions packages/payment-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@samchon/payment-backend",
"version": "5.0.0",
"version": "5.0.1",
"description": "Payment Backend Server",
"main": "lib/index.js",
"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 && tsc -p packages/api/tsconfig.json",
"build:main": "rimraf lib && tsc",
"build:main": "npm run build:prisma && rimraf lib && tsc",
"build:prisma": "prisma generate --schema=src/schema.prisma",
"build:sdk": "rimraf src/api/functional && nestia sdk",
"build:swagger": "nestia swagger",
Expand Down Expand Up @@ -52,7 +52,7 @@
},
"homepage": "https://github.com/samchon/payments",
"devDependencies": {
"@nestia/sdk": "^2.3.0",
"@nestia/sdk": "^2.3.4",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"@types/atob": "^2.1.2",
"@types/bcryptjs": "^2.4.4",
Expand All @@ -67,34 +67,35 @@
"@typescript-eslint/parser": "^5.26.0",
"cli": "^1.0.1",
"copyfiles": "^2.4.1",
"iamport-server-api": "^5.0.0",
"iamport-server-api": "^5.0.1",
"nestia": "^5.0.1",
"pm2": "^4.5.6",
"prettier": "^2.6.2",
"prisma-markdown": "^1.0.0",
"rimraf": "^3.0.2",
"sloc": "^0.2.1",
"toss-payments-server-api": "^5.0.0",
"toss-payments-server-api": "^5.0.1",
"ts-node": "^10.9.1",
"ts-patch": "^3.0.2",
"typescript": "^5.2.2",
"typescript-transform-paths": "^3.4.6"
},
"dependencies": {
"@nestia/core": "^2.3.0",
"@nestia/core": "^2.3.4",
"@prisma/client": "^5.3.1",
"bcryptjs": "^2.4.3",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
"fake-iamport-server": "^5.0.0",
"fake-toss-payments-server": "^5.0.0",
"fake-iamport-server": "^5.0.1",
"fake-toss-payments-server": "^5.0.1",
"git-last-commit": "^1.0.0",
"inquirer": "^8.2.5",
"mutex-server": "^0.3.1",
"prisma": "^5.3.1",
"serialize-error": "^4.1.0",
"source-map-support": "^0.5.19",
"tstl": "^2.5.13",
"typia": "^5.2.3"
"typia": "^5.2.4"
},
"files": [
"lib",
Expand Down
18 changes: 10 additions & 8 deletions packages/payment-backend/src/PaymentConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export namespace PaymentConfiguration {
/* -----------------------------------------------------------
CONNECTIONS
----------------------------------------------------------- */
export const API_PORT = () => Number(PaymentGlobal.env.API_PORT);
export const UPDATOR_PORT = () => Number(PaymentGlobal.env.UPDATOR_PORT);
export const API_PORT = () => Number(PaymentGlobal.env.PAYMENT_API_PORT);
export const UPDATOR_PORT = () =>
Number(PaymentGlobal.env.PAYMENT_UPDATOR_PORT);
export const MASTER_IP = () =>
PaymentGlobal.mode === "local"
? "127.0.0.1"
Expand All @@ -28,10 +29,11 @@ export namespace PaymentConfiguration {
: "your-real-server-master-ip";

export const ENCRYPTION_PASSWORD = (): Readonly<IEncryptionPassword> => ({
key: PaymentGlobal.env.API_ENCRYPTION_KEY ?? "",
iv: PaymentGlobal.env.API_ENCRYPTION_IV ?? "",
key: PaymentGlobal.env.PAYMENT_CONNECTION_ENCRYPTION_KEY ?? "",
iv: PaymentGlobal.env.PAYMENT_CONNECTION_ENCRYPTION_IV ?? "",
});
export const SYSTEM_PASSWORD = () => PaymentGlobal.env.SYSTEM_PASSWORD;
export const SYSTEM_PASSWORD = () =>
PaymentGlobal.env.PAYMENT_SYSTEM_PASSWORD;

/* -----------------------------------------------------------
VENDORS
Expand All @@ -56,8 +58,8 @@ export namespace PaymentConfiguration {
): IIamportUser.IAccessor => {
storeId;
return {
imp_key: PaymentGlobal.env.IAMPORT_KEY,
imp_secret: PaymentGlobal.env.IAMPORT_SECRET,
imp_key: PaymentGlobal.env.PAYMENT_IAMPORT_KEY,
imp_secret: PaymentGlobal.env.PAYMENT_IAMPORT_SECRET,
};
};

Expand All @@ -77,7 +79,7 @@ export namespace PaymentConfiguration {
*/
export const TOSS_SECRET_KEY = (storeId: string): string => {
storeId;
return PaymentGlobal.env.TOSS_PAYMENTS_SECRET;
return PaymentGlobal.env.PAYMENT_TOSS_PAYMENTS_SECRET;
};

/**
Expand Down
50 changes: 25 additions & 25 deletions packages/payment-backend/src/PaymentGlobal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class PaymentGlobal {
* - real: 실제 서버
*/
public static get mode(): "local" | "dev" | "real" {
return (modeWrapper.value ??= environments.get().MODE);
return (modeWrapper.value ??= environments.get().PAYMENT_MODE);
}

public static setMode(mode: typeof PaymentGlobal.mode): void {
Expand Down Expand Up @@ -79,35 +79,35 @@ const modeWrapper: IMode = {};

interface IEnvironments {
// DEFAULT CONFIGURATIONS
MODE: "local" | "dev" | "real";
API_PORT: `${number}`;
UPDATOR_PORT: `${number}`;
SYSTEM_PASSWORD: string;
PAYMENT_MODE: "local" | "dev" | "real";
PAYMENT_API_PORT: `${number}`;
PAYMENT_UPDATOR_PORT: `${number}`;
PAYMENT_SYSTEM_PASSWORD: string;

// POSTGRES CONNECTION INFO
POSTGRES_URL: string;
POSTGRES_HOST: string;
POSTGRES_PORT: `${number}`;
POSTGRES_DATABASE: string;
POSTGRES_SCHEMA: string;
POSTGRES_USERNAME: string;
POSTGRES_USERNAME_READONLY: string;
POSTGRES_PASSWORD: string;
PAYMENT_POSTGRES_HOST: string;
PAYMENT_POSTGRES_PORT: `${number}`;
PAYMENT_POSTGRES_DATABASE: string;
PAYMENT_POSTGRES_SCHEMA: string;
PAYMENT_POSTGRES_USERNAME: string;
PAYMENT_POSTGRES_USERNAME_READONLY: string;
PAYMENT_POSTGRES_PASSWORD: string;
PAYMENT_POSTGRES_URL: string;

// ENCRYPTION KEYS
API_ENCRYPTION_KEY: string;
API_ENCRYPTION_IV: string;
DB_HISTORY_ENCRYPTION_KEY: string;
DB_HISTORY_ENCRYPTION_IV: string;
DB_RESERVATION_ENCRYPTION_KEY: string;
DB_RESERVATION_ENCRYPTION_IV: string;
DB_CANCEL_HISTORY_ENCRYPTION_KEY: string;
DB_CANCEL_HISTORY_ENCRYPTION_IV: string;
PAYMENT_CONNECTION_ENCRYPTION_KEY: string;
PAYMENT_CONNECTION_ENCRYPTION_IV: string;
PAYMENT_HISTORY_ENCRYPTION_KEY: string;
PAYMENT_HISTORY_ENCRYPTION_IV: string;
PAYMENT_RESERVATION_ENCRYPTION_KEY: string;
PAYMENT_RESERVATION_ENCRYPTION_IV: string;
PAYMENT_CANCEL_HISTORY_ENCRYPTION_KEY: string;
PAYMENT_CANCEL_HISTORY_ENCRYPTION_IV: string;

// VENDOR'S SECRETS
IAMPORT_KEY: string;
IAMPORT_SECRET: string;
TOSS_PAYMENTS_SECRET: string;
PAYMENT_IAMPORT_KEY: string;
PAYMENT_IAMPORT_SECRET: string;
PAYMENT_TOSS_PAYMENTS_SECRET: string;
}

const environments: Singleton<IEnvironments> = new Singleton(() => {
Expand All @@ -121,7 +121,7 @@ const prismaClient = new Singleton(
new PrismaClient({
datasources: {
db: {
url: PaymentGlobal.env.POSTGRES_URL,
url: PaymentGlobal.env.PAYMENT_POSTGRES_URL,
},
},
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/payment-backend/src/PaymentSetupWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export namespace PaymentSetupWizard {
execute("dev")("--name init");

await client.$executeRawUnsafe(
`GRANT SELECT ON ALL TABLES IN SCHEMA ${PaymentGlobal.env.POSTGRES_SCHEMA} TO ${PaymentGlobal.env.POSTGRES_USERNAME_READONLY}`,
`GRANT SELECT ON ALL TABLES IN SCHEMA ${PaymentGlobal.env.PAYMENT_POSTGRES_SCHEMA} TO ${PaymentGlobal.env.PAYMENT_POSTGRES_USERNAME_READONLY}`,
);
}

Expand Down
Loading

0 comments on commit 4038bcc

Please sign in to comment.