Giter Site home page Giter Site logo

slonik-interceptor-preset's Introduction

slonik-interceptor-preset

Travis build status NPM version Canonical Code Style Twitter Follow

Slonik interceptor preset.

Motivation

Slonik functionality is extendable using interceptors. Each interceptor is contained in a separate package. Installing and configuring each interceptor becomes a tedious task when using Slonik across multiple projects. slonik-interceptor-preset provides a factory function (createInterceptors) for constructing a collection of selected interceptors.

slonik-interceptor-preset installs these presets:

Name Description
slonik-interceptor-field-name-transformation Transforms Slonik query result field names.
slonik-interceptor-query-benchmarking Benchmarks Slonik queries.
slonik-interceptor-query-logging Logs Slonik queries.
slonik-interceptor-query-normalisation Normalises Slonik queries.

Each interceptor can be selectively enabled/ disabled (see API).

API

import {
  createInterceptors
} from 'slonik-interceptor-preset';
/**
 * @property benchmarkQueries Dictates whether to enable the [query benchmarking interceptor](https://github.com/gajus/slonik-interceptor-query-benchmarking). (Default: false)
 * @property logQueries Dictates whether to enable the [query logging interceptor](https://github.com/gajus/slonik-interceptor-query-logging). (Default: true)
 * @property normaliseQueries Dictates whether to enable the [query normalisation interceptor](https://github.com/gajus/slonik-interceptor-query-normalisation). (Default: true)
 * @property transformFieldNames Dictates whether to enable the [field name transformation interceptor](https://github.com/gajus/slonik-interceptor-field-name-transformation). (Default: true)
 */
type UserConfigurationType = {|
  +benchmarkQueries: boolean,
  +logQueries: boolean,
  +normaliseQueries: boolean,
  +transformFieldNames: boolean
|};

(userConfiguration: UserConfigurationType) => $ReadOnlyArray<InterceptorType>;

Example usage

import {
  createPool
} from 'slonik';
import {
  createInterceptors
} from 'slonik-interceptor-preset';

const connection = createPool('postgres://', {
  interceptors: [
    ...createInterceptors()
  ]
});

slonik-interceptor-preset's People

Contributors

gajus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

slonik-interceptor-preset's Issues

TypeScript support

Would you consider adding TypeScript support to all of your interceptors ?

TypeScript type definitions

I would love to use this package in my TypeScript project, but the lack of types prevents this. Is there any way I can help get types for this package? Thank you for Slonik ๐Ÿ’™!

make slonik a dev dependency

Since slonik is only used for types in this and all the child packages, could it be relegated to devDependencies? The dependency in package.json (16.8.0) isn't the latest version so by using this it's causing multiple copies of slonik to end up in my node_modules.

As a separate suggestion - might it make sense for this and all the other slonik-* packages be moved to https://github.com/gajus/slonik and that repo be made a lerna/yarn monorepo? That way it'd make it easier to apply fixed versioning to packages that do depend on slonik, test, track issues etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.