Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kristiandupont/kanel
Generate Typescript types from Postgres
https://github.com/kristiandupont/kanel
Last synced: 10 days ago
JSON representation
Generate Typescript types from Postgres
- Host: GitHub
- URL: https://github.com/kristiandupont/kanel
- Owner: kristiandupont
- License: mit
- Created: 2020-02-18T19:08:09.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-24T16:33:00.000Z (15 days ago)
- Last Synced: 2024-10-25T16:17:56.363Z (14 days ago)
- Language: TypeScript
- Homepage: https://kristiandupont.github.io/kanel/
- Size: 6.77 MB
- Stars: 874
- Watchers: 6
- Forks: 62
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-typesafe - kristiandupont/kanel - Generate Typescript types from Postgres. (**1. Libraries** / Database)
README
![Kanel Logo](./logo-bright.png#gh-light-mode-only)
![Kanel Logo](./logo-dark.png#gh-dark-mode-only)Generate Typescript types from a live Postgres database.
This is for people who don't like ORM's but who do like intellisense and type checking for their database access code.
See the documentation [here](https://kristiandupont.github.io/kanel)
Introduction to the idea is outlined [here](https://medium.com/@kristiandupont/generating-typescript-types-from-postgres-48661868ef84).
## Usage
Install with:
```bash
$ npm i -D kanel
```To run, make sure you are in a folder that has a `.kanelrc.js` configuration file and that your database is running, and type:
```bash
$ npx kanel
```## Programmatical usage
Example of running generation from code:
```typescript
import { processDatabase } from "kanel";
import config from "./kanelrc";async function run() {
await processDatabase(config);
}run();
```## Example
To see an example of the result, check out the [/example](example) folder. It uses the [Sample Database](https://www.postgresqltutorial.com/postgresql-sample-database/) from www.postgresqltutorial.com.
---
If you want to learn about how I use this together with [tRPC](https://trpc.io/) to create end-to-end type safety with PostgreSQL as the source of truth, check out my course on Newline:
---
---
## Contributors
Made with [contrib.rocks](https://contrib.rocks).