Approval Route Contract Schema (routes/approvals.routes.ts)

deepchat · src/shared/contracts/routes/approvals.routes.ts · typescript · Apache-2.0
dev-tools, database, automation, lang:typescript, fw:zod, tag:routes

Zod schema defining the approval resolution route contract with request ID validation and decision enum.

// Source: https://github.com/ThinkInAIXYZ/deepchat | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { z } from 'zod'
import { defineRouteContract } from '../contract'

export const ApprovalRequestIdSchema = z
  .string()
  .min(16)
  .max(128)
  .regex(/^[A-Za-z0-9_-]+$/)

export const approvalsResolveRoute = defineRouteContract({
  name: 'approvals.resolve',
  input: z
    .object({
      requestId: ApprovalRequestIdSchema,
      decision: z.enum(['approved', 'denied'])
    })
    .strict(),
  output: z.object({ accepted: z.boolean() }).strict()
})

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key