@opengis/fastify-table
Version:
core-plugins
12 lines (9 loc) • 602 B
JavaScript
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 || req.pg?.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;
}