Skip to content

Commit

Permalink
chore: add cache to trusted status
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Jan 23, 2024
1 parent e8615cd commit 8d103ea
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions apps/api/src/routes/trusted/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import type { Handler } from 'express';

import logger from '@hey/lib/logger';
import catchedError from '@utils/catchedError';
import { TRUSTED_PROFILE_FEATURE_ID } from '@utils/constants';
import {
SWR_CACHE_AGE_10_MINS_30_DAYS,
TRUSTED_PROFILE_FEATURE_ID
} from '@utils/constants';
import createClickhouseClient from '@utils/createClickhouseClient';
import prisma from '@utils/prisma';
import { noBody } from '@utils/responses';
Expand Down Expand Up @@ -40,11 +43,14 @@ export const get: Handler = async (req, res) => {

logger.info(`Trusted profile status fetched: ${id}`);

return res.status(200).json({
isTrusted: data?.profileId === id,
resolvedCount: Number(result[0]?.count) || 0,
success: true
});
return res
.status(200)
.setHeader('Cache-Control', SWR_CACHE_AGE_10_MINS_30_DAYS)
.json({
isTrusted: data?.profileId === id,
resolvedCount: Number(result[0]?.count) || 0,
success: true
});
} catch (error) {
return catchedError(res, error);
}
Expand Down

0 comments on commit 8d103ea

Please sign in to comment.