Skip to content

Commit

Permalink
refactor: do not use cache for info route
Browse files Browse the repository at this point in the history
  • Loading branch information
logotip4ik committed Aug 20, 2023
1 parent e500732 commit 1614875
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions server/api/info/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import parseDuration from 'parse-duration';

interface Info {
commit: string
version: string
Expand All @@ -11,7 +9,7 @@ interface Info {
notes?: number
}

export default defineCachedEventHandler(async (event) => {
export default defineEventHandler(async (event) => {
const { build, public: config } = useRuntimeConfig();

const info: Info = {
Expand Down Expand Up @@ -39,21 +37,4 @@ export default defineCachedEventHandler(async (event) => {
}

return info;
}, {
swr: true,
maxAge: parseDuration('24hours', 'second'),
getKey: (event) => {
const { build } = useRuntimeConfig(event);

const prefix = typeof getQuery(event)[build.id] === 'undefined' ? '' : 'guarded-';

return `${prefix}api-info`;
},
shouldInvalidateCache: (event) => {
const { build } = useRuntimeConfig(event);
const query = getQuery(event);

return typeof query[build.id] !== 'undefined'
&& typeof query.invalidateCache !== 'undefined';
},
});

0 comments on commit 1614875

Please sign in to comment.