Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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 --help

Options:
--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;
```