Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pyldin601/postgres-iots-codegen
Utility that generates io-ts contracts from postgresql database schema.
https://github.com/pyldin601/postgres-iots-codegen
Last synced: about 1 month ago
JSON representation
Utility that generates io-ts contracts from postgresql database schema.
- Host: GitHub
- URL: https://github.com/pyldin601/postgres-iots-codegen
- Owner: pyldin601
- License: mit
- Created: 2019-01-05T19:48:29.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T05:36:55.000Z (about 1 year ago)
- Last Synced: 2024-12-08T22:00:13.567Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 292 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# postgres-iots-codegen
Command line utility that generates io-ts contracts from postgresql database schema.## How to use
Type in your console `npx pgiotsgen --help` to get help:
```text
Generates io-ts contracts from postgresql database schema.Usage:
pgiotsgen --host= [--port=] --username= --password= --database= --outdir= [--capital] [--nosuffix] [--index] [--ignore=] [--enum]
pgiotsgen --helpOptions:
--help Show this screen.
-h --host= Specifies the host name of the machine on which the server is running.
-p --port= Specifies the TCP port on which the server is listening for connections.
-u --username= User name to connect as.
-w --password= Password used to connect.
-d --database= Database name to connect to.
-o --outdir= Directory to generate contracts to.
-i --index Also generate root index.ts file for generated contracts.
-c --capital Name contract files with a capital letter.
-s --nosuffix Don't append contract file names with "Contract" suffix.
-t --ignore= Comma separated list of tables that should be ignored.
-e --enum Create enum with table names inside the index file (if --index specified)
```## Example of produced contract file
```typescript
import * as t from "io-ts";export const UsersEntityContract = t.interface({
id: t.number, // integer nullable: NO
name: t.string, // character varying nullable: NO
email: t.string, // character varying nullable: NO
token: t.string, // character varying nullable: NO
});export type IUsersEntity = t.TypeOf;
```