UNPKG

@opengis/fastify-table

Version:

core-plugins

52 lines (51 loc) 1.63 kB
const userClsParamsSchema = { type: "object", properties: { name: { type: "string" }, }, required: ["name"], }; const addUserClsBodySchema = { type: "object", properties: { name: { type: "string" }, data: {}, table: { type: "string" }, }, required: ["name", "data"], }; const editUserClsBodySchema = { type: "object", properties: { data: {}, table: { type: "string" }, }, required: ["data"], }; import getUserCls from "./controllers/getUserCls.js"; import addUserCls from "./controllers/addUserCls.js"; import editUserCls from "./controllers/editUserCls.js"; import deleteUserCls from "./controllers/deleteUserCls.js"; export default function plugin(app) { if (!app.hasRoute({ method: "GET", url: "/api/user-cls" })) { app.get("/user-cls", { config: { policy: "L1" } }, getUserCls); } if (!app.hasRoute({ method: "POST", url: "/api/user-cls" })) { app.post("/user-cls", { config: { policy: "L1" }, schema: { body: addUserClsBodySchema }, }, addUserCls); } if (!app.hasRoute({ method: "PUT", url: "/api/user-cls/:name" })) { app.put("/user-cls/:name", { config: { policy: "L1" }, schema: { params: userClsParamsSchema, body: editUserClsBodySchema, }, }, editUserCls); } if (!app.hasRoute({ method: "DELETE", url: "/api/user-cls/:name" })) { app.delete("/user-cls/:name", { config: { policy: "L1" }, schema: { params: userClsParamsSchema } }, deleteUserCls); } }