Files
outline/plugins/slack/server/auth/schema.ts
Apoorv Mishra 3561b79d65 Zod schemas for routes under /plugins (#6378)
* fix: schema for slack routes

* fix: slack.post

* fix: email
2024-01-13 10:55:30 +05:30

32 lines
903 B
TypeScript

import isEmpty from "lodash/isEmpty";
import { z } from "zod";
import { BaseSchema } from "@server/routes/api/schema";
export const SlackCommandsSchema = BaseSchema.extend({
query: z
.object({
code: z.string().nullish(),
state: z.string().uuid().nullish(),
error: z.string().nullish(),
})
.refine((req) => !(isEmpty(req.code) && isEmpty(req.error)), {
message: "one of code or error is required",
}),
});
export type SlackCommandsReq = z.infer<typeof SlackCommandsSchema>;
export const SlackPostSchema = BaseSchema.extend({
query: z
.object({
code: z.string().nullish(),
state: z.string().uuid().nullish(),
error: z.string().nullish(),
})
.refine((req) => !(isEmpty(req.code) && isEmpty(req.error)), {
message: "one of code or error is required",
}),
});
export type SlackPostReq = z.infer<typeof SlackPostSchema>;