UNPKG

@seasketch/geoprocessing

Version:

Geoprocessing and reporting framework for SeaSketch 2.0

43 lines 1.69 kB
import fs from "fs-extra"; export const projectMetadata = async (event) => { const manifest = (await fs.readJson("./manifest.json")); const { preprocessingFunctions, geoprocessingFunctions, ...projectInfo } = manifest; const uri = `https://${event.headers["Host"]}/prod/`; const project = { ...projectInfo, ...(process.env.clientDistributionUrl ? { clientSideBundle: `https://${process.env.clientDistributionUrl}?service=${uri}`, } : {}), uri, geoprocessingServices: geoprocessingFunctions .filter((f) => f.purpose === "geoprocessing") .map((func) => ({ ...func, endpoint: `https://${event.headers["Host"]}/prod/${func.title}`, handler: undefined, purpose: undefined, requiresProperties: func.requiresProperties || [], })), preprocessingServices: preprocessingFunctions .filter((f) => f.purpose === "preprocessing") .map((func) => ({ title: func.title, description: func.description, endpoint: `https://${event.headers["Host"]}/prod/${func.title}`, requiresProperties: func.requiresProperties || [], })), }; return { statusCode: 200, headers: { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Credentials": true, "Cache-Control": "max-age=30, stale-while-revalidate=86400", }, body: JSON.stringify(project, null, " "), }; }; //# sourceMappingURL=serviceHandlers.js.map