Add pagination, complete organization routes
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { FastifyInstance } from "fastify";
|
||||
import { $org } from "./organization.schema";
|
||||
import { createOrgHandler, getOrgHandler } from "./organization.controller";
|
||||
import {
|
||||
createOrgHandler,
|
||||
deleteOrgHandler,
|
||||
getOrgHandler,
|
||||
listOrgsHandler,
|
||||
updateOrgHandler,
|
||||
} from "./organization.controller";
|
||||
|
||||
export default function organizationRoutes(fastify: FastifyInstance) {
|
||||
fastify.post(
|
||||
@@ -33,4 +39,43 @@ export default function organizationRoutes(fastify: FastifyInstance) {
|
||||
},
|
||||
getOrgHandler
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
"/",
|
||||
{
|
||||
schema: {
|
||||
querystring: $org("pageQueryParams"),
|
||||
response: { 200: $org("listOrgResponse") },
|
||||
},
|
||||
config: { requiredClaims: ["org:read"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
listOrgsHandler
|
||||
);
|
||||
|
||||
fastify.patch(
|
||||
"/:orgId",
|
||||
{
|
||||
schema: {
|
||||
params: { type: "object", properties: { orgId: { type: "string" } } },
|
||||
body: $org("updateOrgInput"),
|
||||
response: {
|
||||
200: $org("createOrgResponse"),
|
||||
},
|
||||
},
|
||||
},
|
||||
updateOrgHandler
|
||||
);
|
||||
|
||||
fastify.delete(
|
||||
"/:orgId",
|
||||
{
|
||||
schema: {
|
||||
params: { type: "object", properties: { orgId: { type: "string" } } },
|
||||
},
|
||||
config: { requiredClaims: ["org:delete"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
deleteOrgHandler
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user