Slonik interceptor preset.
npm install slonik-interceptor-preset



Slonik interceptor preset.
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).
``js
import {
createInterceptors
} from 'slonik-interceptor-preset';
`
`js
/**
* @property benchmarkQueries Dictates whether to enable the query benchmarking interceptor. (Default: false)
* @property logQueries Dictates whether to enable the query logging interceptor. (Default: true)
* @property normaliseQueries Dictates whether to enable the query normalisation interceptor. (Default: true)
* @property transformFieldNames Dictates whether to enable the field name transformation interceptor. (Default: true)
*/
type UserConfigurationType = {|
+benchmarkQueries: boolean,
+logQueries: boolean,
+normaliseQueries: boolean,
+transformFieldNames: boolean
|};
(userConfiguration: UserConfigurationType) => $ReadOnlyArray
`
`js
import {
createPool
} from 'slonik';
import {
createInterceptors
} from 'slonik-interceptor-preset';
const connection = createPool('postgres://', {
interceptors: [
...createInterceptors()
]
});
``