@opengis/fastify-table
Version:
core-plugins
25 lines (24 loc) • 1.01 kB
JavaScript
import update from "./controllers/update.js";
import insert from "./controllers/insert.js";
import deleteCrud from "./controllers/deleteCrud.js";
import table from "./controllers/table.js";
const tableSchema = {
type: "object",
properties: {
params: {
id: { type: "string", pattern: "^([\\w\\d_.]+)$" },
table: { type: "string", pattern: "^([\\w\\d_.]+)$" },
},
},
};
const policy = "L0";
function plugin(app, opt = {}) {
app.put("/table/:table/:id?", { config: { policy, description: "Edit table data" }, schema: tableSchema }, update);
app.delete("/table/:table/:id?", {
config: { policy, description: "Delete table data" },
schema: tableSchema,
}, deleteCrud);
app.post("/table/:table/:id?", { config: { policy, description: "Add table data" }, schema: tableSchema }, insert);
app.get("/table/:table/:id?", { config: { policy, description: "Get table data" }, schema: tableSchema }, table);
}
export default plugin;