UNPKG

next-ts-api

Version:

A powerful TypeScript-first API client generator for Next.js applications with full type safety and automatic api type generation.

36 lines (35 loc) 1.14 kB
interface RouteInfo { path: string; methods: { [key: string]: { importPath: string; exportName: string; }; }; } export interface NextTsApiOptions { /** * Location of the Next.js project. Defaults to the current working directory. * * This is only necessary when working with a non standard NextJS project setup, such as Nx. * * Example: * * // next.config.js * const { nextTsApi } = require('next-ts-api/config') * const withNextTsApi = nextTsApi({ dir: __dirname }); */ dir?: string | undefined; /** * The file path indicating the output directory where the generated route types */ outDir?: string | undefined; /** * The file name of the output file. */ outFile?: string | undefined; } export declare function findRouteFiles(dir: string, routes?: RouteInfo[], basePath?: string[]): RouteInfo[]; export declare function generateTypeDefinitions(routes: RouteInfo[], options: Required<NextTsApiOptions>): string; export declare function writeNextTsApi(options?: NextTsApiOptions): void; export {};