Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
psteinroe committed Jan 3, 2023
2 parents 51dd431 + e6bd586 commit d9acd6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# supabase-to-zod

<div align="center">
<img src="assets/supabase-to-zod-logo.jpg" width="200px" align="center" />
<h1 align="center">supabase-to-zod</h1>
Expand All @@ -18,4 +16,7 @@ $ supabase gen types typescript --local > types.ts
$ pnpm supabase-to-zod --input types.ts --output schemas.ts
```

That's it, go to `types.ts` file, you should have a schema for all tables, views, enums and functions.
That's it, go to `schemas.ts` file, you should have a schema for all tables, views, enums and functions.

## Authors Note
This project was created in a few hours during the Launchweek VI hackathon and the approach is **very** hacky: It transforms the nested `Database` type generated by the Supabase CLI into flat types, and passes them through `ts-to-zod` to generate zod schemas. A proper solution would be using the pg-meta API to generate zod schemas directly from the source of truth, similar to how the Typescript types are generated.
6 changes: 6 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
}

0 comments on commit d9acd6f

Please sign in to comment.