UNPKG

vite-plugin-api-routes

Version:

A Vite.js plugin that creates API routes by mapping the directory structure, similar to Next.js API Routes. This plugin enhances the functionality for backend development using Vite.

44 lines (40 loc) 1.25 kB
import { InlineConfig, PluginOption } from 'vite'; type DirRoute = { dir: string; route: string; exclude?: string[]; skip?: "development" | "production" | string | boolean; }; type ApiOpts = { moduleId?: string; mode?: "legacy" | "isolated"; server?: string; handler?: string; configure?: string; dirs?: DirRoute[]; include?: string[]; exclude?: string[]; mapper?: { [k: string]: false | string | { method: string; priority: number; }; }; filePriority?: number; paramPriority?: number; routeBase?: string; root?: string; cacheDir?: string; forceRestart?: boolean; disableBuild?: boolean; clientOutDir?: string; clientMinify?: boolean | "terser" | "esbuild"; clientBuild?: (config: InlineConfig) => InlineConfig; serverOutDir?: string; serverMinify?: boolean | "terser" | "esbuild"; serverBuild?: (config: InlineConfig) => InlineConfig; }; declare const pluginAPIRoutes: (opts?: ApiOpts) => PluginOption; declare const pluginAPI: (opts?: ApiOpts) => PluginOption; declare const createAPI: (opts?: ApiOpts) => PluginOption; export { createAPI, pluginAPIRoutes as default, pluginAPI, pluginAPIRoutes };