UNPKG

@cocalc/hub

Version:
30 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const webapp_configuration_1 = require("@cocalc/hub/webapp-configuration"); const database_1 = require("../database"); const manifest_1 = require("@cocalc/hub/manifest"); function init(router, isPersonal) { const webappConfig = new webapp_configuration_1.WebappConfiguration({ db: database_1.database }); router.get("/customize", async (req, res) => { // If we're behind cloudflare, we expose the detected country in the client. // Use a lib like https://github.com/michaelwittig/node-i18n-iso-countries // to read the ISO 3166-1 Alpha 2 codes. // If it is unknown, the code will be XX. "K1" is the Tor-Network. 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") { // Used for progressive webapp info. (0, manifest_1.send)(res, config); } else { // Otherwise, just send the data back as json, for the client to parse. res.json(config); } }); } exports.default = init; //# sourceMappingURL=customize.js.map