@opengis/fastify-table
Version:
core-plugins
26 lines (21 loc) • 797 B
JavaScript
import getAppSettings from './controllers/properties.get.js';
import postAppSettings from './controllers/properties.post.js';
const propertiesSchema = {
type: 'object',
properties: {
params: {
id: { type: 'string', pattern: '^([\\d\\w]+)$' },
key: { type: 'string', pattern: '^([\\d\\w._]+)$' },
},
querystring: {
json: { type: 'string', pattern: '^([\\d\\w]+)$' },
},
},
};
const policy = ['site']; // cms etc.
async function plugin(app, config = {}) {
const { prefix = '/api' } = config;
app.get(`${prefix}/settings-app/:entity?`, { config: { policy }, schema: propertiesSchema }, getAppSettings);
app.post(`${prefix}/settings-app/:entity?`, { config: { policy: ['admin'] } }, postAppSettings);
}
export default plugin;