UNPKG

@zenstackhq/server

Version:

ZenStack server-side adapters

35 lines (34 loc) 1.36 kB
import { Response } from '../../types'; import { RequestContext } from '../base'; /** * Request handler options */ export type Options = { /** * The base endpoint of the RESTful API, must be a valid URL */ endpoint: string; /** * The default page size for limiting the number of results returned * from collection queries, including resource collection, related data * of collection types, and relashionship of collection types. * * Defaults to 100. Set to Infinity to disable pagination. */ pageSize?: number; /** * The divider used to separate compound ID fields in the URL. * Defaults to '_'. */ idDivider?: string; /** * The charset used for URL segment values. Defaults to `a-zA-Z0-9-_~ %`. You can change it if your entity's ID values * allow different characters. Specifically, if your models use compound IDs and the idDivider is set to a different value, * it should be included in the charset. */ urlSegmentCharset?: string; modelNameMapping?: Record<string, string>; externalIdMapping?: Record<string, string>; }; export default function makeHandler(options: Options): ({ prisma, method, path, query, requestBody, logger, modelMeta, zodSchemas, }: RequestContext) => Promise<Response>; export { makeHandler as RestApiHandler };