add get processed route
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
||||
import { PageQueryParams } from "../pagination";
|
||||
import {
|
||||
getProcessedPermit,
|
||||
getUniqueValuesProcessed,
|
||||
listProcessedPermits,
|
||||
} from "./processed.service";
|
||||
@@ -28,6 +29,30 @@ export async function processedRoutes(fastify: FastifyInstance) {
|
||||
}
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
"/:permitId",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: "object",
|
||||
properties: { permitId: { type: "string" } },
|
||||
},
|
||||
},
|
||||
config: { requiredClaims: ["permit:read"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
async (req: FastifyRequest, res: FastifyReply) => {
|
||||
const { permitId } = req.params as { permitId: string };
|
||||
|
||||
try {
|
||||
const permit = await getProcessedPermit(permitId, req.user.tenantId);
|
||||
return res.code(200).send(permit);
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
"/fields/:field",
|
||||
{
|
||||
|
||||
@@ -3,6 +3,12 @@ import { getFilterObject, getSortObject, PageQueryParams } from "../pagination";
|
||||
import { userModel } from "../user/user.schema";
|
||||
import { processedFields, processedModel } from "./processed.schema";
|
||||
|
||||
export async function getProcessedPermit(permitId: String, tenantId: String) {
|
||||
return await processedModel.findOne({
|
||||
$and: [{ tenantId: tenantId }, { pid: permitId }],
|
||||
});
|
||||
}
|
||||
|
||||
export async function listProcessedPermits(
|
||||
params: PageQueryParams,
|
||||
tenantId: string
|
||||
|
||||
Reference in New Issue
Block a user