permit and processed collection updates
This commit is contained in:
@@ -4,8 +4,9 @@ import {
|
||||
getProcessedPermit,
|
||||
getUniqueValuesProcessed,
|
||||
listProcessedPermits,
|
||||
updateProcessed,
|
||||
} from "./processed.service";
|
||||
import { $processed } from "./processed.schema";
|
||||
import { $processed, UpdateProcessedInput } from "./processed.schema";
|
||||
|
||||
export async function processedRoutes(fastify: FastifyInstance) {
|
||||
fastify.get(
|
||||
@@ -74,6 +75,32 @@ export async function processedRoutes(fastify: FastifyInstance) {
|
||||
}
|
||||
);
|
||||
|
||||
fastify.patch(
|
||||
"/:permitId",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: "object",
|
||||
properties: { permitId: { type: "string" } },
|
||||
},
|
||||
body: $processed("updateProcessedInput"),
|
||||
},
|
||||
config: { requiredClaims: ["permit:write"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
async (req: FastifyRequest, res: FastifyReply) => {
|
||||
const { permitId } = req.params as { permitId: string };
|
||||
const input = req.body as UpdateProcessedInput;
|
||||
|
||||
try {
|
||||
const permit = await updateProcessed(input, permitId, req.user);
|
||||
return res.code(200).send(permit);
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
"/fields/:field",
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user