UNPKG

@opengis/fastify-table

Version:

core-plugins

42 lines (41 loc) 1.42 kB
import { addHook } from "../../../utils.js"; import widgetDel from "./controllers/widget.del.js"; import widgetSet from "./controllers/widget.set.js"; import widgetGet from "./controllers/widget.get.js"; import fileEdit from "./controllers/file.edit.js"; import onWidgetSet from "./hook/onWidgetSet.js"; const tableSchema = { params: { type: "object", properties: { type: { type: "string", enum: [ "gallery", "file", "checklist", "history", "comment", "reaction", ], }, objectid: { type: "string", pattern: "^([\\d\\w]+)$" }, id: { type: "string", pattern: "^([\\d\\w]+)$" }, }, }, querystring: { type: "object", properties: { debug: { type: "string", pattern: "^(\\d+)$" }, }, }, }; addHook("onWidgetSet", onWidgetSet); const policy = "L0"; const params = { config: { policy }, schema: tableSchema }; export default function route(app, opt = {}) { app.delete("/widget/:type/:objectid/:id", params, widgetDel); app.post("/widget/:type/:objectid/:id?", params, widgetSet); app.put("/file-edit/:id", params, fileEdit); app.get("/widget/:type/:objectid", { config: { policy }, schema: tableSchema }, widgetGet); }