feat: initial work unifying new endpoint and generating api key
This commit is contained in:
@@ -10,7 +10,9 @@ export const httpMethod = (allowedHttpMethod: "GET" | "POST" | "PATCH" | "DELETE
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Made this so we can support several HTTP Methods in one route and use it there.
|
||||
// Could be further extracted into a third function or refactored into one.
|
||||
// that checks if it's just a string or an array and apply the correct logic to both cases.
|
||||
export const httpMethods = (allowedHttpMethod: string[]): NextMiddleware => {
|
||||
return async function (req, res, next) {
|
||||
if (allowedHttpMethod.map((method) => method === req.method)) {
|
||||
@@ -27,3 +29,4 @@ export const HTTP_GET = httpMethod("GET");
|
||||
export const HTTP_PATCH = httpMethod("PATCH");
|
||||
export const HTTP_DELETE = httpMethod("DELETE");
|
||||
export const HTTP_GET_DELETE_PATCH = httpMethods(["GET", "DELETE", "PATCH"]);
|
||||
export const HTTP_GET_OR_POST = httpMethods(["GET", "POST"]);
|
||||
|
||||
@@ -2,11 +2,19 @@ import { label } from "next-api-middleware";
|
||||
|
||||
import { addRequestId } from "./addRequestid";
|
||||
import { captureErrors } from "./captureErrors";
|
||||
import { HTTP_POST, HTTP_DELETE, HTTP_PATCH, HTTP_GET, HTTP_GET_DELETE_PATCH } from "./httpMethods";
|
||||
import {
|
||||
HTTP_POST,
|
||||
HTTP_DELETE,
|
||||
HTTP_PATCH,
|
||||
HTTP_GET,
|
||||
HTTP_GET_OR_POST,
|
||||
HTTP_GET_DELETE_PATCH,
|
||||
} from "./httpMethods";
|
||||
import { verifyApiKey } from "./verifyApiKey";
|
||||
|
||||
const withMiddleware = label(
|
||||
{
|
||||
HTTP_GET_OR_POST,
|
||||
HTTP_GET_DELETE_PATCH,
|
||||
HTTP_GET,
|
||||
HTTP_PATCH,
|
||||
|
||||
@@ -2,9 +2,9 @@ import { withValidation } from "next-validations";
|
||||
|
||||
import { _PaymentModel as Payment } from "@calcom/prisma/zod";
|
||||
|
||||
// FIXME: Payment seems a delicate endpoint, do we need to remove anything here?
|
||||
export const schemaPaymentBodyParams = Payment.omit({ id: true });
|
||||
|
||||
export const schemaPaymentPublic = Payment.omit({});
|
||||
export const schemaPaymentPublic = Payment.omit({ externalId: true });
|
||||
|
||||
export const withValidPayment = withValidation({
|
||||
schema: schemaPaymentBodyParams,
|
||||
|
||||
Reference in New Issue
Block a user