Skip to content

Commit

Permalink
refactor: improve code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rickstaa committed Sep 17, 2023
1 parent ba2d9e3 commit c886f9e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
8 changes: 3 additions & 5 deletions api/gist.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ export default async (req, res) => {

res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
`max-age=${cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
);

Expand All @@ -79,10 +78,9 @@ export default async (req, res) => {
} catch (err) {
res.setHeader(
"Cache-Control",
`max-age=${CONSTANTS.ERROR_CACHE_SECONDS / 2}, s-maxage=${
CONSTANTS.ERROR_CACHE_SECONDS
`max-age=${CONSTANTS.ERROR_CACHE_SECONDS / 2}, s-maxage=${CONSTANTS.ERROR_CACHE_SECONDS
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
); // Cache the error response less frequently.
); // Use lower cache period for errors.
return res.send(renderError(err.message, err.secondaryMessage));
}
};
8 changes: 3 additions & 5 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export default async (req, res) => {

res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
`max-age=${cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
);

Expand Down Expand Up @@ -102,10 +101,9 @@ export default async (req, res) => {
} catch (err) {
res.setHeader(
"Cache-Control",
`max-age=${CONSTANTS.ERROR_CACHE_SECONDS / 2}, s-maxage=${
CONSTANTS.ERROR_CACHE_SECONDS
`max-age=${CONSTANTS.ERROR_CACHE_SECONDS / 2}, s-maxage=${CONSTANTS.ERROR_CACHE_SECONDS
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
); // Cache the error response less frequently.
); // Use lower cache period for errors.
return res.send(renderError(err.message, err.secondaryMessage));
}
};
8 changes: 3 additions & 5 deletions api/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ export default async (req, res) => {

res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
`max-age=${cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
);

Expand All @@ -85,10 +84,9 @@ export default async (req, res) => {
} catch (err) {
res.setHeader(
"Cache-Control",
`max-age=${CONSTANTS.ERROR_CACHE_SECONDS / 2}, s-maxage=${
CONSTANTS.ERROR_CACHE_SECONDS
`max-age=${CONSTANTS.ERROR_CACHE_SECONDS / 2}, s-maxage=${CONSTANTS.ERROR_CACHE_SECONDS
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
); // Cache the error response less frequently.
); // Use lower cache period for errors.
return res.send(renderError(err.message, err.secondaryMessage));
}
};
8 changes: 3 additions & 5 deletions api/top-langs.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ export default async (req, res) => {

res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
`max-age=${cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
);

Expand All @@ -101,10 +100,9 @@ export default async (req, res) => {
} catch (err) {
res.setHeader(
"Cache-Control",
`max-age=${CONSTANTS.ERROR_CACHE_SECONDS / 2}, s-maxage=${
CONSTANTS.ERROR_CACHE_SECONDS
`max-age=${CONSTANTS.ERROR_CACHE_SECONDS / 2}, s-maxage=${CONSTANTS.ERROR_CACHE_SECONDS
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
); // Cache the error response less frequently.
); // Use lower cache period for errors.
return res.send(renderError(err.message, err.secondaryMessage));
}
};

0 comments on commit c886f9e

Please sign in to comment.