UNPKG

@opengis/fastify-table

Version:

core-plugins

14 lines (13 loc) 619 B
import path from "node:path"; import config from "../../../../../config.js"; export default function getFolder(req, type = "server") { if (!["server", "local"].includes(type)) throw new Error("params type is invalid"); const types = { local: req.root || config.root, server: req.mapServerRoot || config.mapServerRoot, }; const dbname = req.pg?.options?.database || config.pg?.database; // request / config params / default config params const filepath = path.posix.join(types[type] || `/data/local/${dbname || ""}`, req.folder || config.folder || ""); return filepath; }