Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (schemas) => {
each(pairs(schemas), ([name, markdown]) => {
const fileName = path.resolve(out, `${name}.md`);
// add YAML frontmatter
const output = (!meta ? '' : '---\n')
+ (!meta ? '' : yaml.safeDump(meta))
+ (!meta ? '' : '---\n\n')
+ processor.stringify(markdown);
fs.writeFile(fileName, output, (err) => {
if (err) {
error(err);
}
// info(`${fileName} created`);
});
function cache(context) {
const res = setdefault(context, 'response', {});
const headers = setdefault(res, 'headers', {});
const directives = {
's-maxage': 30 * 24 * 3600, // serve from cache (without revalidation) for 30 days
'stale-while-revalidate': 365 * 24 * 3600, // serve stale (while revalidating in background) for a year
};
headers['Cache-Control'] = foldl(
pairs(directives),
'',
(a, [key, value]) => `${a + (a ? ', ' : '') + key}=${value}`,
);
}