From 522d79b88319983a3a57f4d3c40228b5554d6b11 Mon Sep 17 00:00:00 2001 From: Michael Kim Date: Tue, 24 Oct 2023 12:28:48 +0900 Subject: [PATCH] Change endpoint of relay --- packages/relay/src/routers/DefaultRouter.ts | 36 ++++++++++----------- packages/relay/test/Endpoints.test.ts | 28 ++++++++-------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/relay/src/routers/DefaultRouter.ts b/packages/relay/src/routers/DefaultRouter.ts index 29f40009..68fff8a5 100644 --- a/packages/relay/src/routers/DefaultRouter.ts +++ b/packages/relay/src/routers/DefaultRouter.ts @@ -194,7 +194,7 @@ export class DefaultRouter { // 포인트를 이용하여 구매 this.app.post( - "/payPoint", + "/ledger/payPoint", [ body("purchaseId").exists(), body("amount").exists().custom(Validation.isAmount), @@ -212,7 +212,7 @@ export class DefaultRouter { // 토큰을 이용하여 구매할 때 this.app.post( - "/payToken", + "/ledger/payToken", [ body("purchaseId").exists(), body("amount").exists().custom(Validation.isAmount), @@ -230,7 +230,7 @@ export class DefaultRouter { // 포인트의 종류를 선택하는 기능 this.app.post( - "/changeToLoyaltyToken", + "/ledger/changeToLoyaltyToken", [ body("account").exists().isEthereumAddress(), body("signature") @@ -242,7 +242,7 @@ export class DefaultRouter { // 사용가능한 포인트로 전환 this.app.post( - "/changeToPayablePoint", + "/ledger/changeToPayablePoint", [ body("phone") .exists() @@ -335,11 +335,11 @@ export class DefaultRouter { /** * 사용자 포인트 지불 - * POST /payPoint + * POST /ledger/payPoint * @private */ private async payPoint(req: express.Request, res: express.Response) { - logger.http(`POST /payPoint`); + logger.http(`POST /ledger/payPoint`); const errors = validationResult(req); if (!errors.isEmpty()) { @@ -393,11 +393,11 @@ export class DefaultRouter { /** * 사용자 토큰 지불 - * POST /payToken + * POST /ledger/payToken * @private */ private async payToken(req: express.Request, res: express.Response) { - logger.http(`POST /payToken`); + logger.http(`POST /ledger/payToken`); const errors = validationResult(req); if (!errors.isEmpty()) { @@ -437,7 +437,7 @@ export class DefaultRouter { } catch (error: any) { let message = ContractUtils.cacheEVMError(error as any); if (message === "") message = "Failed pay token"; - logger.error(`POST /payToken :`, message); + logger.error(`POST /ledger/payToken :`, message); return res.status(200).json( this.makeResponseData(500, undefined, { message, @@ -450,11 +450,11 @@ export class DefaultRouter { /** * 포인트의 종류를 선택한다. - * POST /changeToLoyaltyToken + * POST /ledger/changeToLoyaltyToken * @private */ private async changeToLoyaltyToken(req: express.Request, res: express.Response) { - logger.http(`POST /changeToLoyaltyToken`); + logger.http(`POST /ledger/changeToLoyaltyToken`); const errors = validationResult(req); if (!errors.isEmpty()) { @@ -488,8 +488,8 @@ export class DefaultRouter { return res.status(200).json(this.makeResponseData(200, { txHash: tx.hash })); } catch (error: any) { let message = ContractUtils.cacheEVMError(error as any); - if (message === "") message = "Failed change point type"; - logger.error(`POST /changeToLoyaltyToken :`, message); + if (message === "") message = "Failed change layalty type"; + logger.error(`POST /ledger/changeToLoyaltyToken :`, message); return res.status(200).json( this.makeResponseData(500, undefined, { message, @@ -502,11 +502,11 @@ export class DefaultRouter { /** * 포인트의 종류를 선택한다. - * POST /changeToPayablePoint + * POST /ledger/changeToPayablePoint * @private */ private async changeToPayablePoint(req: express.Request, res: express.Response) { - logger.http(`POST /changeToPayablePoint`); + logger.http(`POST /ledger/changeToPayablePoint`); const errors = validationResult(req); if (!errors.isEmpty()) { @@ -537,12 +537,12 @@ export class DefaultRouter { .connect(signerItem.signer) .changeToPayablePoint(phone, account, signature); - logger.http(`TxHash(setLoyaltyType): `, tx.hash); + logger.http(`TxHash(changeToPayablePoint): `, tx.hash); return res.status(200).json(this.makeResponseData(200, { txHash: tx.hash })); } catch (error: any) { let message = ContractUtils.cacheEVMError(error as any); - if (message === "") message = "Failed change point type"; - logger.error(`POST /setLoyaltyType :`, message); + if (message === "") message = "Failed change to payable point"; + logger.error(`POST /ledger/changeToPayablePoint :`, message); return res.status(200).json( this.makeResponseData(500, undefined, { message, diff --git a/packages/relay/test/Endpoints.test.ts b/packages/relay/test/Endpoints.test.ts index e599b8d2..af4e8086 100644 --- a/packages/relay/test/Endpoints.test.ts +++ b/packages/relay/test/Endpoints.test.ts @@ -427,7 +427,7 @@ describe("Test of Server", function () { ); }); - it("Failure test of the path /payPoint 'Insufficient balance'", async () => { + it("Failure test of the path /ledger/payPoint 'Insufficient balance'", async () => { const over_purchaseAmount = Amount.make(90_000_000, 18).value; const nonce = await ledgerContract.nonceOf(users[purchase.userIndex].address); const signature = await ContractUtils.signPayment( @@ -438,7 +438,7 @@ describe("Test of Server", function () { shop.shopId, nonce ); - const uri = URI(serverURL).directory("payPoint"); + const uri = URI(serverURL).directory("ledger/payPoint"); const url = uri.toString(); const response = await client.post(url, { purchaseId: purchase.purchaseId, @@ -453,7 +453,7 @@ describe("Test of Server", function () { assert.ok(response.data.error.message === "Insufficient balance"); }); - it("Failure test of the path /payPoint 'Invalid signature'", async () => { + it("Failure test of the path /ledger/payPoint 'Invalid signature'", async () => { const purchaseAmount = Amount.make(purchase.amount, 18).value; const nonce = await ledgerContract.nonceOf(users[0].address); const signature = await ContractUtils.signPayment( @@ -464,7 +464,7 @@ describe("Test of Server", function () { shop.shopId, nonce ); - const uri = URI(serverURL).directory("payPoint"); + const uri = URI(serverURL).directory("ledger/payPoint"); const url = uri.toString(); const response = await client.post(url, { purchaseId: purchase.purchaseId, @@ -479,7 +479,7 @@ describe("Test of Server", function () { assert.ok(response.data.error.message === "Signature is not valid."); }); - it("Success Test of the path /payPoint", async () => { + it("Success Test of the path /ledger/payPoint", async () => { const purchaseAmount = Amount.make(purchase.amount, 18).value; const nonce = await ledgerContract.nonceOf(users[0].address); const signature = await ContractUtils.signPayment( @@ -490,7 +490,7 @@ describe("Test of Server", function () { shop.shopId, nonce ); - const uri = URI(serverURL).directory("payPoint"); + const uri = URI(serverURL).directory("ledger/payPoint"); const url = uri.toString(); const response = await client.post(url, { purchaseId: purchase.purchaseId, @@ -508,7 +508,7 @@ describe("Test of Server", function () { assert.ok(response.data.data.txHash !== undefined); }); - it("Failure test of the path /payToken 'Insufficient balance'", async () => { + it("Failure test of the path /ledger/payToken 'Insufficient balance'", async () => { const over_purchaseAmount = Amount.make(90_000_000, 18).value; const nonce = await ledgerContract.nonceOf(users[0].address); const signature = await ContractUtils.signPayment( @@ -519,7 +519,7 @@ describe("Test of Server", function () { shop.shopId, nonce ); - const uri = URI(serverURL).directory("payToken"); + const uri = URI(serverURL).directory("ledger/payToken"); const url = uri.toString(); const response = await client.post(url, { purchaseId: purchase.purchaseId, @@ -534,7 +534,7 @@ describe("Test of Server", function () { assert.ok(response.data.error.message === "Insufficient balance"); }); - it("Failure test of the path /payToken 'Invalid signature'", async () => { + it("Failure test of the path /ledger/payToken 'Invalid signature'", async () => { const purchaseAmount = Amount.make(purchase.amount, 18).value; const nonce = await ledgerContract.nonceOf(users[0].address); const signature = await ContractUtils.signPayment( @@ -545,7 +545,7 @@ describe("Test of Server", function () { shop.shopId, nonce ); - const uri = URI(serverURL).directory("payToken"); + const uri = URI(serverURL).directory("ledger/payToken"); const url = uri.toString(); const response = await client.post(url, { purchaseId: purchase.purchaseId, @@ -560,7 +560,7 @@ describe("Test of Server", function () { assert.ok(response.data.error.message === "Signature is not valid."); }); - it("Success Test of the path /payToken", async () => { + it("Success Test of the path /ledger/payToken", async () => { const purchaseAmount = Amount.make(purchase.amount, 18).value; const nonce = await ledgerContract.nonceOf(users[0].address); const signature = await ContractUtils.signPayment( @@ -571,7 +571,7 @@ describe("Test of Server", function () { shop.shopId, nonce ); - const uri = URI(serverURL).directory("payToken"); + const uri = URI(serverURL).directory("ledger/payToken"); const url = uri.toString(); const response = await client.post(url, { purchaseId: purchase.purchaseId, @@ -599,7 +599,7 @@ describe("Test of Server", function () { const userIndex = 0; const nonce = await ledgerContract.nonceOf(users[userIndex].address); const signature = await ContractUtils.signLoyaltyType(users[userIndex], nonce); - const uri = URI(serverURL).directory("changeToLoyaltyToken"); + const uri = URI(serverURL).directory("ledger/changeToLoyaltyToken"); const url = uri.toString(); const response = await client.post(url, { account: users[userIndex].address, @@ -776,7 +776,7 @@ describe("Test of Server", function () { nonce ); - const uri = URI(serverURL).directory("changeToPayablePoint"); + const uri = URI(serverURL).directory("ledger/changeToPayablePoint"); const url = uri.toString(); const response = await client.post(url, { phone: phoneHash,