add rts routes
This commit is contained in:
98
src/rts/rts.route.ts
Normal file
98
src/rts/rts.route.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import { FastifyInstance } from "fastify";
|
||||
import { $rts } from "./rts.schema";
|
||||
import {
|
||||
createRtsHandler,
|
||||
deleteRtsHandler,
|
||||
getRtsHandler,
|
||||
listRtsHandler,
|
||||
newFilesHandler,
|
||||
updateRtsHandler,
|
||||
} from "./rts.controller";
|
||||
import { hideFields } from "../auth";
|
||||
|
||||
export async function rtsRoutes(fastify: FastifyInstance) {
|
||||
fastify.post(
|
||||
"/",
|
||||
{
|
||||
schema: {
|
||||
body: $rts("rtsCreateInput"),
|
||||
},
|
||||
config: { requiredClaims: ["rts:write"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
createRtsHandler
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
"/:rtsId",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: "object",
|
||||
properties: {
|
||||
rtsId: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
config: { requiredClaims: ["rts:read"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
getRtsHandler
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
"/",
|
||||
{
|
||||
schema: {
|
||||
querystring: $rts("pageQueryParams"),
|
||||
},
|
||||
|
||||
config: { requiredClaims: ["rts:read"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
listRtsHandler
|
||||
);
|
||||
|
||||
fastify.patch(
|
||||
"/:rtsId",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: "object",
|
||||
properties: { rtsId: { type: "string" } },
|
||||
},
|
||||
body: $rts("rtsUpdateInput"),
|
||||
},
|
||||
},
|
||||
updateRtsHandler
|
||||
);
|
||||
|
||||
fastify.delete(
|
||||
"/:rtsId",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: "object",
|
||||
properties: { rtsId: { type: "string" } },
|
||||
},
|
||||
},
|
||||
config: { requiredClaims: ["rts:delete"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
deleteRtsHandler
|
||||
);
|
||||
|
||||
fastify.post(
|
||||
"/:rtsId/files",
|
||||
{
|
||||
schema: {
|
||||
body: $rts("rtsNewUpload"),
|
||||
},
|
||||
config: { requiredClaims: ["rts:write"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
newFilesHandler
|
||||
);
|
||||
|
||||
fastify.addHook("onSend", hideFields("rts"));
|
||||
}
|
||||
Reference in New Issue
Block a user