Skip to content

Commit cf82bc0

Browse files
committed
fix typo and cors to all.
1 parent 6448d81 commit cf82bc0

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed

src/pages/api/v1/addTransaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { NextApiRequest, NextApiResponse } from "next";
22
import { db } from "@/server/db";
3-
import { verifyJwt } from "@/lib/verifyJWT";
3+
import { verifyJwt } from "@/lib/verifyJwt";
44

55
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
66
if (req.method !== "POST") {

src/pages/api/v1/authSigner.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ import {
77
DataSignature,
88
deserializeAddress,
99
} from "@meshsdk/core";
10+
import { cors } from "@/lib/cors";
1011

1112
export default async function handler(
1213
req: NextApiRequest,
1314
res: NextApiResponse,
1415
) {
16+
await cors(req, res);
17+
if (req.method === "OPTIONS") {
18+
return res.status(200).end();
19+
}
20+
1521
if (req.method === "GET") {
1622
const { address } = req.query;
1723
if (typeof address !== "string") {

src/pages/api/v1/freeUtxos.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { addressToNetwork } from "@/utils/multisigSDK";
1010
import type { UTxO } from "@meshsdk/core";
1111
import { createCaller } from "@/server/api/root";
1212
import { db } from "@/server/db";
13-
import { verifyJwt } from "@/lib/verifyJWT";
13+
import { verifyJwt } from "@/lib/verifyJwt";
1414

1515
export default async function handler(
1616
req: NextApiRequest,

src/pages/api/v1/lookupMultisigWallet.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
import type { NextApiRequest, NextApiResponse } from "next";
22
import { getProvider } from "@/utils/get-provider";
3+
import { cors } from "@/lib/cors";
34

45
export default async function handler(
56
req: NextApiRequest,
67
res: NextApiResponse,
78
) {
9+
await cors(req, res);
10+
if (req.method === "OPTIONS") {
11+
return res.status(200).end();
12+
}
13+
814
if (req.method !== "GET") {
915
return res.status(405).json({ error: "Method Not Allowed" });
1016
}
1117

1218
const { pubKeyHashes, network = "1" } = req.query;
1319

1420
if (typeof pubKeyHashes !== "string") {
15-
return res.status(400).json({ error: "Missing or invalid pubKeyHashes parameter" });
21+
return res
22+
.status(400)
23+
.json({ error: "Missing or invalid pubKeyHashes parameter" });
1624
}
1725

1826
const hashes = pubKeyHashes.split(",").map((s) => s.trim().toLowerCase());
19-
console.log(hashes)
27+
console.log(hashes);
2028
const networkId = parseInt(network as string, 10);
2129

2230
const provider = getProvider(networkId);
2331

2432
try {
25-
const response = await provider.get('/metadata/txs/labels/1854');
33+
const response = await provider.get("/metadata/txs/labels/1854");
2634

2735
if (!Array.isArray(response)) {
2836
throw new Error("Invalid response format from provider");
@@ -36,7 +44,7 @@ export default async function handler(
3644
const matchedItems = validItems.filter((item: any) => {
3745
const participants = item.json_metadata.participants;
3846
return Object.keys(participants).some((hash: string) =>
39-
hashes.includes(hash.toLowerCase())
47+
hashes.includes(hash.toLowerCase()),
4048
);
4149
});
4250

@@ -45,4 +53,4 @@ export default async function handler(
4553
console.error("lookupWallet error:", error);
4654
res.status(500).json({ error: "Internal Server Error" });
4755
}
48-
}
56+
}

src/pages/api/v1/nativeScript.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1+
import { cors } from "@/lib/cors";
12
import { NextApiRequest, NextApiResponse } from "next";
23
import { Wallet as DbWallet } from "@prisma/client";
34
import { buildMultisigWallet } from "@/utils/common";
4-
import { verifyJwt } from "@/lib/verifyJWT";
5+
import { verifyJwt } from "@/lib/verifyJwt";
56
import { createCaller } from "@/server/api/root";
67
import { db } from "@/server/db";
78

89
export default async function handler(
910
req: NextApiRequest,
1011
res: NextApiResponse,
1112
) {
13+
await cors(req, res);
14+
if (req.method === "OPTIONS") {
15+
return res.status(200).end();
16+
}
1217
if (req.method !== "GET") {
1318
return res.status(405).json({ error: "Method Not Allowed" });
1419
}

src/pages/api/v1/walletIds.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { NextApiRequest, NextApiResponse } from "next";
22
import { createCaller } from "@/server/api/root";
33
import { db } from "@/server/db";
4-
import { verifyJwt } from "@/lib/verifyJWT";
4+
import { verifyJwt } from "@/lib/verifyJwt";
5+
import { cors } from "@/lib/cors";
56

67
export default async function handler(
78
req: NextApiRequest,
89
res: NextApiResponse,
910
) {
11+
await cors(req, res);
12+
if (req.method === "OPTIONS") {
13+
return res.status(200).end();
14+
}
15+
1016
if (req.method !== "GET") {
1117
return res.status(405).json({ error: "Method Not Allowed" });
1218
}

0 commit comments

Comments
 (0)