update role claims, refactor getUniqueValues

This commit is contained in:
2025-05-16 17:25:39 +05:30
parent 4028c05d5f
commit c73d57410a
15 changed files with 114 additions and 191 deletions

View File

@@ -5,12 +5,8 @@ import {
deleteNoteHandler,
updateNoteHandler,
} from "./note.controller";
import { Claim } from "../utils/claims";
export async function noteRoutes(
fastify: FastifyInstance,
claims: { read: Claim; write: Claim; delete: Claim }
) {
export async function noteRoutes(fastify: FastifyInstance) {
fastify.post(
"/:resourceId/notes",
{
@@ -20,7 +16,7 @@ export async function noteRoutes(
properties: { resourceId: { type: "string" } },
},
},
config: { requiredClaims: [claims.write] },
config: { requiredClaims: ["note:write"] },
preHandler: [fastify.authorize],
},
createNoteHandler
@@ -35,7 +31,7 @@ export async function noteRoutes(
properties: { resourceId: { type: "string" } },
},
},
config: { requiredClaims: [claims.read] },
config: { requiredClaims: ["note:read"] },
preHandler: [fastify.authorize],
},
listNotesHandler
@@ -53,7 +49,7 @@ export async function noteRoutes(
},
},
},
config: { requiredClaims: [claims.write] },
config: { requiredClaims: ["note:write"] },
preHandler: [fastify.authorize],
},
updateNoteHandler
@@ -71,7 +67,7 @@ export async function noteRoutes(
},
},
},
config: { requiredClaims: [claims.write] },
config: { requiredClaims: ["note:delete"] },
preHandler: [fastify.authorize],
},
deleteNoteHandler