import { send as sendManifest } from "@cocalc/hub/manifest";
import { WebappConfiguration } from "@cocalc/hub/webapp-configuration";
import { database } from "../database";
export default function init(router, isPersonal: boolean) {
const webappConfig = new WebappConfiguration({ db: database });
router.get("/customize", async (req, res) => {
const country = req.headers["cf-ipcountry"] ?? "XX";
const host = req.headers["host"];
const config = await webappConfig.get({ host, country });
if (isPersonal) {
config.configuration.is_personal = true;
}
if (req.query.type === "manifest") {
sendManifest(res, config);
} else {
res.json(config);
}
});
}