Socket
Book a DemoInstallSign in
Socket

@pgtyped/cli

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pgtyped/cli

This package provides the `pgtyped` command. `pgtyped` supports two modes: normal and watch mode.

Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
25K
29.02%
Maintainers
1
Weekly downloads
 
Created
Source

@pgtyped/cli

This package provides the pgtyped command.
pgtyped supports two modes: normal and watch mode.

In normal mode, pgtyped operates as follows:

  • Scans your srcDir for query files. Query file name format is specified using the queryFileName config option.
  • Extracts all queries defined in query files using the sql tagged template.
  • Connects to your database and fetches the input and output types for all the queries found in step 3.
  • For each query file, saves its queries type declaration in a query type declaration file (defined by the emitFileName option of the config.
  • Exit

Watch mode operation is the same, except that pgtyped doesn't exit after processing all files, but continues running in the background, watching srcDir for changes and regenerating query types files on file change or creation.

Config file:

Config file format (config.json):

{
  "emit": {
    "mode": "query-file", // Only query-file mode is supported at the moment. 
    "queryFileName": "queries.ts", // Filenames to scan for SQL queries
    "emitFileName": "queries.types.ts" // Filenames to save type information into
  },
  "srcDir": "./src/", // Directory to scan or watch for query files
  "db": {
    "dbName": "testdb", // DB name
    "user": "user", // DB username
    "password": "password", // DB password (optional)
    "host": "127.0.0.1" // DB host (optional)
  }
}

This package is part of the pgtyped project.
Refer to root README for details.

FAQs

Package last updated on 11 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts