88 lines
1.7 KiB
TypeScript
88 lines
1.7 KiB
TypeScript
import { FastifyInstance } from "fastify";
|
|
import {
|
|
createViewHandler,
|
|
deleteViewHandler,
|
|
getViewHandler,
|
|
listViewHandler,
|
|
updateViewHandler,
|
|
} from "./view.controller";
|
|
import { $view } from "./view.schema";
|
|
|
|
export async function viewRoutes(fastify: FastifyInstance) {
|
|
fastify.post(
|
|
"/",
|
|
{
|
|
schema: {
|
|
body: $view("createViewInput"),
|
|
},
|
|
config: { requiredClaims: ["view:write"] },
|
|
preHandler: [fastify.authorize],
|
|
},
|
|
createViewHandler
|
|
);
|
|
|
|
fastify.get(
|
|
"/",
|
|
{
|
|
schema: {
|
|
querystring: $view("pageQueryParams"),
|
|
},
|
|
config: { requiredClaims: ["view:read"] },
|
|
preHandler: [fastify.authorize],
|
|
},
|
|
listViewHandler
|
|
);
|
|
|
|
fastify.get(
|
|
"/:viewId",
|
|
{
|
|
schema: {
|
|
params: {
|
|
type: "object",
|
|
properties: {
|
|
viewId: { type: "string" },
|
|
},
|
|
},
|
|
},
|
|
config: { requiredClaims: ["view:read"] },
|
|
preHandler: [fastify.authorize],
|
|
},
|
|
getViewHandler
|
|
);
|
|
|
|
fastify.patch(
|
|
"/:viewId",
|
|
{
|
|
schema: {
|
|
params: {
|
|
type: "object",
|
|
properties: {
|
|
viewId: { type: "string" },
|
|
},
|
|
},
|
|
body: $view("updateViewInput"),
|
|
},
|
|
config: { requiredClaims: ["view:write"] },
|
|
preHandler: [fastify.authorize],
|
|
},
|
|
updateViewHandler
|
|
);
|
|
|
|
fastify.delete(
|
|
"/:viewId",
|
|
{
|
|
schema: {
|
|
params: {
|
|
type: "object",
|
|
properties: {
|
|
viewId: { type: "string" },
|
|
},
|
|
},
|
|
},
|
|
config: { requiredClaims: ["view:delete"] },
|
|
preHandler: [fastify.authorize],
|
|
},
|
|
deleteViewHandler
|
|
);
|
|
}
|