silverwolf-x's picture
download
raw
583 Bytes
import type { NextApiResponse } from "next";
import { serialize, CookieSerializeOptions } from "cookie";
/**
* This sets `cookie` using the `res` object
*/
export const setCookie = (
res: NextApiResponse,
name: string,
value: unknown,
options: CookieSerializeOptions = {},
) => {
const stringValue =
typeof value === "object" ? "j:" + JSON.stringify(value) : String(value);
if (typeof options.maxAge === "number") {
options.expires = new Date(Date.now() + options.maxAge * 1000);
}
res.setHeader("Set-Cookie", serialize(name, stringValue, options));
};

Xet Storage Details

Size:
583 Bytes
·
Xet hash:
98365954a55f0ef769890607fae951a93b44916d355dbf9c44989df75c902a79

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.