@pg-nano/plugin-typebox
v0.1.0-beta.3
Published
This plugin generates [TypeBox](https://github.com/sinclairzx81/typebox) runtime type validators for your Postgres tables, enums, and composite types.
Downloads
4
Readme
@pg-nano/plugin-typebox
This plugin generates TypeBox runtime type validators for your Postgres tables, enums, and composite types.
You must manually integrate the type validators with your application server's API layer (how is up to you). It's not used automatically by the Postgres function wrappers generated by pg-nano itself, as it's assumed that you've validated your data by the time you call into Postgres.
Under the hood, it uses typebox-codegen to generate the TypeBox definitions from the TypeScript types that were derived from the Postgres schema by pg-nano.
Usage
import typebox from '@pg-nano/plugin-typebox'
export default defineConfig({
plugins: [
typebox({
// Optional: A shell command to run after generating the TypeBox
// definitions. The main use case is to format the generated code
// into a more readable form.
formatScript: 'pnpm format',
})
],
})