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 => foldl(schemas, {}, (pv, schema) => {
const slugger = ghslugger();
// eslint-disable-next-line no-param-reassign
pv[schema[s.slug]] = root([
// todo add more elements
...makeheader(schema),
...maketypesection(schema, 1),
...makeconstraintssection(schema, 1),
...makedefault(schema, 1),
...makeexamples(schema, 1),
...makedefinitions(schema, slugger),
...makeproperties(schema, slugger),
]);
return pv;
});
}
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}`,
);
}
function generatenames(schemas) {
const slugger = new GithubSlugger();
return foldl(schemas, {}, (container, schema) => {
const name = {};
name[slugger.slug(schema.title)] = schema;
return Object.assign(container, name);
});
}