Skip to content

Commit

Permalink
Added caching
Browse files Browse the repository at this point in the history
  • Loading branch information
taha-abbasi committed Mar 31, 2023
1 parent 6749a33 commit 04a6930
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,9 @@ import cacheMiddleware from './cacheMiddleware';

const app = express();
const port = process.env.PORT || 8080;
// const cache = new NodeCache({ stdTTL: 60 }); // 60 seconds TTL

app.use(bodyParser.json());

// const cacheMiddleware = (duration: number) => {
// return (req: Request, res: Response, next: NextFunction) => {
// const key = req.originalUrl;
// const cachedResponse = cache.get(key);

// if (cachedResponse) {
// res.send(cachedResponse);
// } else {
// const originalSend = res.send.bind(res);

// res.send = ((body: any) => {
// cache.set(key, body, duration);
// originalSend(body);
// }) as Response['send'];

// next();
// }
// };
// }

app.get("/totalSupplyAcrossNetworks", cacheMiddleware(60), async (req, res) => {
try {
const { tokenContractAddress, chainId } = req.query;
Expand Down

0 comments on commit 04a6930

Please sign in to comment.