1 | import { format } from '@tusbar/cache-control';
|
2 | const SECOND = { unit: 'second', relativeTo: '1970-01-01' };
|
3 | const isDuration = (x) => (x === null || x === void 0 ? void 0 : x[Symbol.toStringTag]) === 'Temporal.Duration';
|
4 | export const caching = (options = {}) => async (ax) => {
|
5 | const x = await ax;
|
6 | const opts = Object.fromEntries(Object.entries(options).map(([k, v]) => [k, isDuration(v) ? v.total(SECOND) : v]));
|
7 | x.effects.push(res => res.headers.set('Cache-Control', format(opts)));
|
8 | return x;
|
9 | };
|
10 |
|
\ | No newline at end of file |