import { Response } from "express";
import { join } from "path";
import { SiteSettingsKeys } from "@cocalc/util/db-schema/site-defaults";
import base_path from "@cocalc/backend/base-path";
interface Custom {
configuration: Record<SiteSettingsKeys, string>;
}
export function send(res: Response, custom: Custom) {
const config = custom.configuration;
res.header("Content-Type", "application/manifest+json");
const base_app = join(base_path, "app");
const manifest = {
name: config.site_name,
short_name: config.site_name,
start_url: `${base_app}?utm_medium=manifest`,
scope: base_path,
display: "minimal-ui",
background_color: "#fbb635",
theme_color: "#4474c0",
description: config.site_description,
icons: [
{
src:
config.logo_square ??
"https://storage.googleapis.com/cocalc-extra/cocalc-icon-white-fillin.256px.png",
sizes: "256x256",
type: "image/png",
},
],
};
res.send(JSON.stringify(manifest, null, 2));
}