import Cookies from "cookies";
import { Router } from "express";
import { getLogger } from "@cocalc/hub/logger";
const { COOKIE_OPTIONS } = require("@cocalc/hub/client");
export default function init(router: Router) {
const winston = getLogger("set-cookie");
router.get("/cookies", (req, res) => {
if (req.query.set) {
const maxAge = 1000 * 24 * 3600 * 30 * 6;
winston.debug(`${req.query.set}=${req.query.value}`);
const cookies = new Cookies(req, res, { secure: true });
const conf = { ...COOKIE_OPTIONS, maxAge };
winston.debug(`conf=${JSON.stringify(conf)}`);
cookies.set(req.query.set, req.query.value, conf);
}
res.end();
});
}