Skip to content

Commit a6d63e2

Browse files
committed
update kv usage
1 parent 6a54383 commit a6d63e2

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

apps/web/pages/api/checkNftProof/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { NextApiRequest, NextApiResponse } from 'next';
2-
import { redis } from 'apps/web/src/utils/redis';
2+
import { kv } from 'apps/web/src/utils/kv';
33
import { logger } from 'apps/web/src/utils/logger';
44

55
type RequestBody = {
@@ -21,7 +21,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
2121
const { address } = req.body as RequestBody;
2222

2323
try {
24-
const proof = await redis.get<string[]>(`proof:${address}`);
24+
const proof = await kv.get<string[]>(`proof:${address}`);
2525

2626
if (proof) {
2727
return res.status(200).json({ result: proof });

apps/web/pages/api/registry/entries.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { NextApiRequest, NextApiResponse } from 'next';
22
import { db } from 'apps/web/src/utils/ocsRegistry';
3-
import { redis } from 'apps/web/src/utils/redis';
3+
import { kv } from 'apps/web/src/utils/kv';
44
import { logger } from 'apps/web/src/utils/logger';
55
import { withTimeout } from 'apps/web/pages/api/decorators';
66

77
const pageKey = 'api.ocs_registry.entries';
88
async function handler(req: NextApiRequest, res: NextApiResponse) {
9-
const redisClient = await redis.getClient();
109
const { page = '1', limit = '10', category, curation } = req.query;
1110

1211
const pageNum = parseInt(page as string, 10);
@@ -50,7 +49,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
5049
};
5150

5251
try {
53-
await redisClient.incr(`stat:requests.${pageKey}`);
52+
await kv.incr(`stat:requests.${pageKey}`);
5453
} catch (error) {
5554
logger.error('error getting registry entries', error);
5655
}

apps/web/pages/api/registry/featured.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { NextApiRequest, NextApiResponse } from 'next';
22
import { db } from 'apps/web/src/utils/ocsRegistry';
3-
import { redis } from 'apps/web/src/utils/redis';
3+
import { kv } from 'apps/web/src/utils/kv';
44
import { logger } from 'apps/web/src/utils/logger';
55
import { withTimeout } from 'apps/web/pages/api/decorators';
66

77
const pageKey = 'api.ocs_registry.featured';
88
async function handler(req: NextApiRequest, res: NextApiResponse) {
9-
const redisClient = await redis.getClient();
109
const content = await db
1110
.selectFrom('content')
1211
.where('is_featured', '=', true)
@@ -21,7 +20,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
2120
};
2221

2322
try {
24-
await redisClient.incr(`stat:requests.${pageKey}`);
23+
await kv.incr(`stat:requests.${pageKey}`);
2524
} catch (error) {
2625
logger.error('error getting featured registry entries', error);
2726
}

apps/web/src/utils/proofs/sybil_resistance.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getAttestations } from '@coinbase/onchainkit/identity';
2-
import { redis } from 'apps/web/src/utils/redis'
2+
import { kv } from 'apps/web/src/utils/kv';
33
import { CoinbaseProofResponse } from 'apps/web/pages/api/proofs/coinbase';
44
import RegistrarControllerABI from 'apps/web/src/abis/RegistrarControllerABI';
55
import {
@@ -193,7 +193,7 @@ export async function sybilResistantUsernameSigning(
193193

194194
const kvKey = `${previousClaimsKVPrefix}${idemKey}`;
195195
//check kv for previous claim entries
196-
let previousClaims = (await redis.get<PreviousClaims>(kvKey)) ?? {};
196+
let previousClaims = (await kv.get<PreviousClaims>(kvKey)) ?? {};
197197
const previousClaim = previousClaims[discountType];
198198
if (previousClaim) {
199199
if (previousClaim.address != address) {
@@ -223,7 +223,7 @@ export async function sybilResistantUsernameSigning(
223223
const claim: PreviousClaim = { address, signedMessage };
224224
previousClaims[discountType] = claim;
225225

226-
await redis.set<PreviousClaims>(kvKey, previousClaims, { nx: true, ex: parseInt(EXPIRY) });
226+
await kv.set<PreviousClaims>(kvKey, previousClaims, { nx: true, ex: parseInt(EXPIRY) });
227227

228228
return {
229229
signedMessage: claim.signedMessage,

0 commit comments

Comments
 (0)