added doga

This commit is contained in:
szabomarton
2025-02-25 09:55:29 +01:00
parent 5174ab4cc4
commit 13254e5623
1149 changed files with 80161 additions and 0 deletions

24
25_02_24/node_modules/@tinyhttp/res/dist/cookie.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import * as cookie from '@tinyhttp/cookie';
import { sign } from '@tinyhttp/cookie-signature';
import { append } from './append.js';
export const setCookie = (req, res) => (name, value, options = {}) => {
const secret = req.secret;
const signed = options.signed || false;
if (signed && !secret)
throw new Error('cookieParser("secret") required for signed cookies');
let val = typeof value === 'object' ? `j:${JSON.stringify(value)}` : String(value);
if (signed)
val = `s:${sign(val, secret)}`;
if (options.maxAge) {
options.expires = new Date(Date.now() + options.maxAge);
options.maxAge /= 1000;
}
if (options.path == null)
options.path = '/';
append(res)('Set-Cookie', `${cookie.serialize(name, String(val), options)}`);
return res;
};
export const clearCookie = (req, res) => (name, options) => {
return setCookie(req, res)(name, '', Object.assign({}, { expires: new Date(1), path: '/' }, options));
};
//# sourceMappingURL=cookie.js.map