add notes to payments, unique values route
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import { FastifyInstance } from "fastify";
|
import { FastifyInstance } from "fastify";
|
||||||
import { getPaymentHandler, listPaymentHandler } from "./payment.controller";
|
import { getPaymentHandler, listPaymentHandler } from "./payment.controller";
|
||||||
import { $payment } from "./payment.schema";
|
import { $payment } from "./payment.schema";
|
||||||
|
import { getUniqueFields } from "../unique";
|
||||||
|
import { noteRoutes } from "../note/note.route";
|
||||||
|
|
||||||
export async function paymentRoutes(fastify: FastifyInstance) {
|
export async function paymentRoutes(fastify: FastifyInstance) {
|
||||||
fastify.get(
|
fastify.get(
|
||||||
@@ -43,4 +45,30 @@ export async function paymentRoutes(fastify: FastifyInstance) {
|
|||||||
},
|
},
|
||||||
listPaymentHandler
|
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 { rtsModel } from "./rts/rts.schema";
|
||||||
import { taskModel } from "./task/task.schema";
|
import { taskModel } from "./task/task.schema";
|
||||||
import { AuthenticatedUser } from "./auth";
|
import { AuthenticatedUser } from "./auth";
|
||||||
|
import { paymentModel } from "./payments/payment.schema";
|
||||||
|
|
||||||
type Collection =
|
type Collection =
|
||||||
| "users"
|
| "users"
|
||||||
@@ -14,7 +15,8 @@ type Collection =
|
|||||||
| "processed"
|
| "processed"
|
||||||
| "notifications"
|
| "notifications"
|
||||||
| "rts"
|
| "rts"
|
||||||
| "task";
|
| "task"
|
||||||
|
| "payment";
|
||||||
|
|
||||||
const modelMap = {
|
const modelMap = {
|
||||||
users: userModel,
|
users: userModel,
|
||||||
@@ -24,6 +26,7 @@ const modelMap = {
|
|||||||
notifications: notificationModel,
|
notifications: notificationModel,
|
||||||
rts: rtsModel,
|
rts: rtsModel,
|
||||||
task: taskModel,
|
task: taskModel,
|
||||||
|
payment: paymentModel,
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function getUniqueFields(
|
export async function getUniqueFields(
|
||||||
|
|||||||
Reference in New Issue
Block a user