winterspec
Version:
Write Winter-CG compatible routes with filesystem routing and tons of features
36 lines (35 loc) • 1.15 kB
JavaScript
import { z } from "zod";
const winterSpecConfigSchema = z
.object({
/**
* Defaults to the current working directory.
*/
rootDirectory: z.string().optional(),
/**
* If this path is relative, it's resolved relative to the `rootDirectory` option.
*/
tsconfigPath: z.string().optional(),
/**
* If this path is relative, it's resolved relative to the `rootDirectory` option.
*/
routesDirectory: z.string().optional(),
/**
* The platform you're targeting.
*
* Defaults to `wintercg-minimal`, and you should use this whenever possible for maximal compatibility.
*
* Check [the docs](https://github.com/tscircuit/winterspec/blob/main/docs/winterspec-config.md) for more information.
*/
platform: z
.enum(["node", "wintercg-minimal"])
.default("wintercg-minimal")
.optional(),
})
.strict();
export const defineConfig = (config) => {
const parsedConfig = winterSpecConfigSchema.safeParse(config);
if (parsedConfig.success) {
return parsedConfig.data;
}
throw new Error(`Invalid config: ${parsedConfig.error}`);
};