backend: refactor server/nodeinfo.ts #221

Merged
norm merged 5 commits from refactor-nodeinfo into main 2022-11-02 21:42:52 +00:00
Showing only changes of commit 4abfacaf16 - Show all commits

View file

@ -109,17 +109,15 @@ const nodeinfo2 = async (): Promise<NodeInfo2Base> => {
}; };
}; };
const cache = new Cache<NodeInfo2Base>(10 * MINUTE);
router.get(nodeinfo2_1path, async ctx => { router.get(nodeinfo2_1path, async ctx => {
norm marked this conversation as resolved Outdated

Is this cache even necessary? Maybe we should rely on the caching of the reverse proxy more.

Is this cache even necessary? Maybe we should rely on the caching of the reverse proxy more.

Does the reverse proxy cache it by default?

Does the reverse proxy cache it by default?
const base = await cache.fetch(null, () => nodeinfo2()); const base = await nodeinfo2();
ctx.body = { version: '2.1', ...base }; ctx.body = { version: '2.1', ...base };
ctx.set('Cache-Control', 'public, max-age=600'); ctx.set('Cache-Control', 'public, max-age=600');
}); });
router.get(nodeinfo2_0path, async ctx => { router.get(nodeinfo2_0path, async ctx => {
const base = await cache.fetch(null, () => nodeinfo2()); const base = await nodeinfo2();
delete base.software.repository; delete base.software.repository;