mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 19:44:52 +00:00
requested changes
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import fp from "fastify-plugin";
|
||||
|
||||
import { DefaultResponseErrorsSchema } from "../routes/sanitizedSchemas";
|
||||
|
||||
export const addErrorsToResponseSchemas = fp(async (server) => {
|
||||
server.addHook("onRoute", (routeOptions) => {
|
||||
if (routeOptions.schema && routeOptions.schema.response) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
routeOptions.schema.response = {
|
||||
...DefaultResponseErrorsSchema,
|
||||
...routeOptions.schema.response
|
||||
};
|
||||
} else {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
routeOptions.schema = routeOptions.schema || {};
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
routeOptions.schema.response = { ...DefaultResponseErrorsSchema };
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user