unique field route for notifications
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
listNotificationsHandler,
|
||||
updateNotificationHandler,
|
||||
} from "./notification.controller";
|
||||
import { getUniqueValuesNotification } from "./notification.service";
|
||||
|
||||
export async function notificationRoutes(fastify: FastifyInstance) {
|
||||
fastify.post(
|
||||
@@ -43,4 +44,33 @@ export async function notificationRoutes(fastify: FastifyInstance) {
|
||||
},
|
||||
updateNotificationHandler
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
"/fields/:field",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: "object",
|
||||
properties: {
|
||||
field: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
config: { requiredClaims: ["notification:read"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
async (req, res) => {
|
||||
const { field } = req.params as { field: string };
|
||||
|
||||
try {
|
||||
const uniqueValues = await getUniqueValuesNotification(
|
||||
field,
|
||||
req.user.tenantId
|
||||
);
|
||||
return res.code(200).send(uniqueValues);
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user