npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts-slonik-live-server-plugin

v1.1.12

Published

Typescript language service plugin for slonik.

Downloads

81

Readme

ts-slonik-live-server-plugin

Typescript language server plugin for slonik.

This plugin tests slonik sql template tag queries, suggests table & column names and checks it's cost against a live database.

Installation

yarn add -D ts-slonik-live-server-plugin

or

npm i -D ts-slonik-live-server-plugin

Settings

Add to plugins section in tsconfig.json:

{
  "compilerOptions": {
    ...
    "plugins": [
      {
        "name": "ts-slonik-live-server-plugin",
        "dotEnv": "../.env",
        "pg": {
          "uri": "postgresql://localhost/postgres",
          "defaultSchema": "public",
          "infoTtl": 5000,
          "include": {
            "schema": ["public", "users"],
            "table": ["schema1.table1"]
          },
          "exclude": {
            "table": ["schema1.table1"]
          }
        },
        "cost": {
          "info": true,
          "threshold": {
            "error": 100,
            "warning": 50
          }
        }
      }
    ]
  }
}

VS Code

https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin#testing-locally

Note: If you're using Visual Studio Code, you'll have to use the first approach above, with a path to the module, or run the "TypeScript: Select TypeScript Version" command and choose "Use Workspace > Version", or click the version number between "TypeScript" and 😃 in the lower-right corner. Otherwise, VS Code will not be able to find your plugin.

Postgres connection

Connection settings can be defined by following options:

pg.uri

If pg.uri is set under plugin setting in tsconfig.json, any .env configuration will be ignored.

.env

The plugin will by default look for .env file in project root. If the file is located elsewhere (e.g. monorepo), you can add it's relative path to the project root with dotEnv setting.

You can use node-postgres environment variables in .env file, or you can define Postgres connection URI with PGURI environment variable. If PGURI is defined, any node-postgres environment variables will be ignored.

Schemas and tables

By default, any tables in public schema will be tested against. You can override this preset with include and exclude rules.

pg.defaultSchema

Default: public

If your default schema is other than public, add it's name to defaultSchema option.

pg.infoTtl

Default: 5000

TTL (in milliseconds) of DB information. The DB information (a.k.a. Database schema in broader RDBMS terminolgy) will be only refetched after the TTL have surpassed from last load time.

pg.include

pg.include.schema

Default: ["public"]

You can override default schema with this setting. Be adviced that default schema will not be added automatically.

pg.include.table

Default: []

If you wish to add tables which are not under any schemas in pg.include.schema setting, you can add them with pg.include.table setting.

If table is in schema other than the default schema, define the table name as schemaName.tableName (without double quotes).

pg.exclude

pg.exclude.table

Default: []

Just like pg.include.table, you can define any tables that you wish to explicitly omit to test against.

Cost

Cost is evaluated by explain query.

cost.info

Default: true

If set to true, all query costs will be advised via code suggestion.

cost.threshold.error

Default: 100

Any cost over this value will be code error.

cost.threshold.warning

Default: 50

Any cost over this value will be code warning.

Notes

This project was inspired by ts-sql-plugin