@bit-js/byte
Version:
A simple, performance-focused web framework that works on Bun, Deno, and browsers.
22 lines (21 loc) • 914 B
TypeScript
import { type BaseContext } from '../../core';
interface TypeMap {
string: string | null;
number: number;
bool: boolean;
file: File | null;
}
export interface FormPropertyOptions {
type: keyof TypeMap;
multipleItems?: boolean;
}
export type InferFormPropertyOptions<T extends FormPropertyOptions> = T['multipleItems'] extends true ? (TypeMap[T['type']])[] : TypeMap[T['type']];
export type FormSchema = Record<string, FormPropertyOptions>;
export type InferFormSchema<Schema extends FormSchema> = {
[K in keyof Schema]: InferFormPropertyOptions<Schema[K]> & {};
};
export declare const form: {
get<Options extends FormPropertyOptions>(prop: string, { type, multipleItems }: Options): (ctx: BaseContext) => Promise<InferFormPropertyOptions<Options>>;
schema<Schema extends FormSchema>(schema: Schema): (ctx: BaseContext) => Promise<InferFormSchema<Schema> | null>;
};
export {};