added client role and related code
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { PageQueryParams } from '../pagination';
|
||||
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
||||
import { PageQueryParams } from "../pagination";
|
||||
import {
|
||||
getProcessedPermit,
|
||||
getUniqueValuesProcessed,
|
||||
listProcessedPermits,
|
||||
updateProcessed,
|
||||
} from './processed.service';
|
||||
import { $processed, UpdateProcessedInput } from './processed.schema';
|
||||
import { noteRoutes } from '../note/note.route';
|
||||
} from "./processed.service";
|
||||
import { $processed, UpdateProcessedInput } from "./processed.schema";
|
||||
import { noteRoutes } from "../note/note.route";
|
||||
|
||||
export async function processedRoutes(fastify: FastifyInstance) {
|
||||
fastify.get(
|
||||
'/',
|
||||
"/",
|
||||
{
|
||||
schema: {
|
||||
querystring: $processed('pageQueryParams'),
|
||||
querystring: $processed("pageQueryParams"),
|
||||
},
|
||||
config: { requiredClaims: ['permit:read'] },
|
||||
config: { requiredClaims: ["permit:read"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
async (req: FastifyRequest, res: FastifyReply) => {
|
||||
const params = req.query as PageQueryParams;
|
||||
|
||||
try {
|
||||
const permits = await listProcessedPermits(params, req.user.tenantId);
|
||||
const permits = await listProcessedPermits(params, req.user);
|
||||
return res.code(200).send(permits);
|
||||
} catch (err) {
|
||||
return err;
|
||||
@@ -32,19 +32,19 @@ export async function processedRoutes(fastify: FastifyInstance) {
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
'/search',
|
||||
"/search",
|
||||
{
|
||||
schema: {
|
||||
querystring: $processed('pageQueryParams'),
|
||||
querystring: $processed("pageQueryParams"),
|
||||
},
|
||||
config: { requiredClaims: ['permit:read'] },
|
||||
config: { requiredClaims: ["permit:read"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
async (req: FastifyRequest, res: FastifyReply) => {
|
||||
const params = req.query as PageQueryParams;
|
||||
|
||||
try {
|
||||
const permits = await listProcessedPermits(params, req.user.tenantId);
|
||||
const permits = await listProcessedPermits(params, req.user);
|
||||
return res.code(200).send(permits);
|
||||
} catch (err) {
|
||||
return err;
|
||||
@@ -53,15 +53,15 @@ export async function processedRoutes(fastify: FastifyInstance) {
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
'/:permitId',
|
||||
"/:permitId",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: 'object',
|
||||
properties: { permitId: { type: 'string' } },
|
||||
type: "object",
|
||||
properties: { permitId: { type: "string" } },
|
||||
},
|
||||
},
|
||||
config: { requiredClaims: ['permit:read'] },
|
||||
config: { requiredClaims: ["permit:read"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
async (req: FastifyRequest, res: FastifyReply) => {
|
||||
@@ -77,16 +77,16 @@ export async function processedRoutes(fastify: FastifyInstance) {
|
||||
);
|
||||
|
||||
fastify.patch(
|
||||
'/:permitId',
|
||||
"/:permitId",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: 'object',
|
||||
properties: { permitId: { type: 'string' } },
|
||||
type: "object",
|
||||
properties: { permitId: { type: "string" } },
|
||||
},
|
||||
body: $processed('updateProcessedInput'),
|
||||
body: $processed("updateProcessedInput"),
|
||||
},
|
||||
config: { requiredClaims: ['permit:write'] },
|
||||
config: { requiredClaims: ["permit:write"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
async (req: FastifyRequest, res: FastifyReply) => {
|
||||
@@ -103,17 +103,17 @@ export async function processedRoutes(fastify: FastifyInstance) {
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
'/fields/:field',
|
||||
"/fields/:field",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: 'object',
|
||||
type: "object",
|
||||
properties: {
|
||||
field: { type: 'string' },
|
||||
field: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
config: { requiredClaims: ['permit:read'] },
|
||||
config: { requiredClaims: ["permit:read"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
async (req: FastifyRequest, res: FastifyReply) => {
|
||||
@@ -132,8 +132,8 @@ export async function processedRoutes(fastify: FastifyInstance) {
|
||||
);
|
||||
|
||||
await noteRoutes(fastify, {
|
||||
read: 'permit:read',
|
||||
write: 'permit:write',
|
||||
delete: 'permit:delete',
|
||||
read: "permit:read",
|
||||
write: "permit:write",
|
||||
delete: "permit:delete",
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user