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: about 14 hours 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 (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-12-02T17:37:13.000Z (11 days ago)
- Last Synced: 2024-12-06T14:01:43.008Z (8 days ago)
- Language: TypeScript
- Homepage: https://kristiandupont.github.io/kanel/
- Size: 6.97 MB
- Stars: 900
- Watchers: 6
- Forks: 63
- Open Issues: 25
-
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).