add notes to payments, unique values route
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { FastifyInstance } from "fastify";
|
||||
import { getPaymentHandler, listPaymentHandler } from "./payment.controller";
|
||||
import { $payment } from "./payment.schema";
|
||||
import { getUniqueFields } from "../unique";
|
||||
import { noteRoutes } from "../note/note.route";
|
||||
|
||||
export async function paymentRoutes(fastify: FastifyInstance) {
|
||||
fastify.get(
|
||||
@@ -43,4 +45,30 @@ export async function paymentRoutes(fastify: FastifyInstance) {
|
||||
},
|
||||
listPaymentHandler
|
||||
);
|
||||
|
||||
fastify.get(
|
||||
"/fields/:field",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: "object",
|
||||
properties: { field: { type: "string" } },
|
||||
},
|
||||
},
|
||||
config: { requiredClaims: ["payment:read"] },
|
||||
preHandler: [fastify.authorize],
|
||||
},
|
||||
async (req, res) => {
|
||||
const { field } = req.params as { field: string };
|
||||
|
||||
try {
|
||||
const uniqueValues = await getUniqueFields(field, "payment", req.user);
|
||||
return res.code(200).send(uniqueValues);
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
await noteRoutes(fastify);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { notificationModel } from "./notification/notification.schema";
|
||||
import { rtsModel } from "./rts/rts.schema";
|
||||
import { taskModel } from "./task/task.schema";
|
||||
import { AuthenticatedUser } from "./auth";
|
||||
import { paymentModel } from "./payments/payment.schema";
|
||||
|
||||
type Collection =
|
||||
| "users"
|
||||
@@ -14,7 +15,8 @@ type Collection =
|
||||
| "processed"
|
||||
| "notifications"
|
||||
| "rts"
|
||||
| "task";
|
||||
| "task"
|
||||
| "payment";
|
||||
|
||||
const modelMap = {
|
||||
users: userModel,
|
||||
@@ -24,6 +26,7 @@ const modelMap = {
|
||||
notifications: notificationModel,
|
||||
rts: rtsModel,
|
||||
task: taskModel,
|
||||
payment: paymentModel,
|
||||
};
|
||||
|
||||
export async function getUniqueFields(
|
||||
|
||||
Reference in New Issue
Block a user