add notes routes to processed

This commit is contained in:
2025-05-01 10:05:34 +05:30
parent 1f9970366c
commit 6d7e1c9f0b

View File

@@ -1,21 +1,22 @@
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify"; import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
import { PageQueryParams } from "../pagination"; import { PageQueryParams } from '../pagination';
import { import {
getProcessedPermit, getProcessedPermit,
getUniqueValuesProcessed, getUniqueValuesProcessed,
listProcessedPermits, listProcessedPermits,
updateProcessed, updateProcessed,
} from "./processed.service"; } from './processed.service';
import { $processed, UpdateProcessedInput } from "./processed.schema"; import { $processed, UpdateProcessedInput } from './processed.schema';
import { noteRoutes } from '../note/note.route';
export async function processedRoutes(fastify: FastifyInstance) { export async function processedRoutes(fastify: FastifyInstance) {
fastify.get( fastify.get(
"/", '/',
{ {
schema: { schema: {
querystring: $processed("pageQueryParams"), querystring: $processed('pageQueryParams'),
}, },
config: { requiredClaims: ["permit:read"] }, config: { requiredClaims: ['permit:read'] },
preHandler: [fastify.authorize], preHandler: [fastify.authorize],
}, },
async (req: FastifyRequest, res: FastifyReply) => { async (req: FastifyRequest, res: FastifyReply) => {
@@ -31,12 +32,12 @@ export async function processedRoutes(fastify: FastifyInstance) {
); );
fastify.get( fastify.get(
"/search", '/search',
{ {
schema: { schema: {
querystring: $processed("pageQueryParams"), querystring: $processed('pageQueryParams'),
}, },
config: { requiredClaims: ["permit:read"] }, config: { requiredClaims: ['permit:read'] },
preHandler: [fastify.authorize], preHandler: [fastify.authorize],
}, },
async (req: FastifyRequest, res: FastifyReply) => { async (req: FastifyRequest, res: FastifyReply) => {
@@ -52,15 +53,15 @@ export async function processedRoutes(fastify: FastifyInstance) {
); );
fastify.get( fastify.get(
"/:permitId", '/:permitId',
{ {
schema: { schema: {
params: { params: {
type: "object", type: 'object',
properties: { permitId: { type: "string" } }, properties: { permitId: { type: 'string' } },
}, },
}, },
config: { requiredClaims: ["permit:read"] }, config: { requiredClaims: ['permit:read'] },
preHandler: [fastify.authorize], preHandler: [fastify.authorize],
}, },
async (req: FastifyRequest, res: FastifyReply) => { async (req: FastifyRequest, res: FastifyReply) => {
@@ -76,16 +77,16 @@ export async function processedRoutes(fastify: FastifyInstance) {
); );
fastify.patch( fastify.patch(
"/:permitId", '/:permitId',
{ {
schema: { schema: {
params: { params: {
type: "object", type: 'object',
properties: { permitId: { type: "string" } }, properties: { permitId: { type: 'string' } },
}, },
body: $processed("updateProcessedInput"), body: $processed('updateProcessedInput'),
}, },
config: { requiredClaims: ["permit:write"] }, config: { requiredClaims: ['permit:write'] },
preHandler: [fastify.authorize], preHandler: [fastify.authorize],
}, },
async (req: FastifyRequest, res: FastifyReply) => { async (req: FastifyRequest, res: FastifyReply) => {
@@ -102,17 +103,17 @@ export async function processedRoutes(fastify: FastifyInstance) {
); );
fastify.get( fastify.get(
"/fields/:field", '/fields/:field',
{ {
schema: { schema: {
params: { params: {
type: "object", type: 'object',
properties: { properties: {
field: { type: "string" }, field: { type: 'string' },
}, },
}, },
}, },
config: { requiredClaims: ["permit:read"] }, config: { requiredClaims: ['permit:read'] },
preHandler: [fastify.authorize], preHandler: [fastify.authorize],
}, },
async (req: FastifyRequest, res: FastifyReply) => { async (req: FastifyRequest, res: FastifyReply) => {
@@ -129,4 +130,10 @@ export async function processedRoutes(fastify: FastifyInstance) {
} }
} }
); );
await noteRoutes(fastify, {
read: 'permit:read',
write: 'permit:write',
delete: 'permit:delete',
});
} }