pg-cache 2.1.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.js +1 -1
- package/esm/pg.js +2 -2
- package/index.d.ts +1 -1
- package/index.js +2 -1
- package/package.json +5 -5
- package/pg.d.ts +1 -0
- package/pg.js +4 -3
package/esm/index.js
CHANGED
package/esm/pg.js
CHANGED
|
@@ -3,7 +3,7 @@ import { getPgEnvOptions } from 'pg-env';
|
|
|
3
3
|
import { Logger } from '@pgpmjs/logger';
|
|
4
4
|
import { pgCache } from './lru';
|
|
5
5
|
const log = new Logger('pg-cache');
|
|
6
|
-
const
|
|
6
|
+
export const buildConnectionString = (user, password, host, port, database) => `postgres://${user}:${password}@${host}:${port}/${database}`;
|
|
7
7
|
export const getPgPool = (pgConfig) => {
|
|
8
8
|
const config = getPgEnvOptions(pgConfig);
|
|
9
9
|
const { user, password, host, port, database, } = config;
|
|
@@ -12,7 +12,7 @@ export const getPgPool = (pgConfig) => {
|
|
|
12
12
|
if (cached)
|
|
13
13
|
return cached;
|
|
14
14
|
}
|
|
15
|
-
const connectionString =
|
|
15
|
+
const connectionString = buildConnectionString(user, password, host, port, database);
|
|
16
16
|
const pgPool = new pg.Pool({ connectionString });
|
|
17
17
|
/**
|
|
18
18
|
* IMPORTANT: Pool-level error handler for idle connection errors.
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPgPool = exports.teardownPgPools = exports.PgPoolCacheManager = exports.pgCache = void 0;
|
|
3
|
+
exports.getPgPool = exports.buildConnectionString = exports.teardownPgPools = exports.PgPoolCacheManager = exports.pgCache = void 0;
|
|
4
4
|
// Main exports from pg-cache package
|
|
5
5
|
var lru_1 = require("./lru");
|
|
6
6
|
Object.defineProperty(exports, "close", { enumerable: true, get: function () { return lru_1.close; } });
|
|
@@ -8,4 +8,5 @@ Object.defineProperty(exports, "pgCache", { enumerable: true, get: function () {
|
|
|
8
8
|
Object.defineProperty(exports, "PgPoolCacheManager", { enumerable: true, get: function () { return lru_1.PgPoolCacheManager; } });
|
|
9
9
|
Object.defineProperty(exports, "teardownPgPools", { enumerable: true, get: function () { return lru_1.teardownPgPools; } });
|
|
10
10
|
var pg_1 = require("./pg");
|
|
11
|
+
Object.defineProperty(exports, "buildConnectionString", { enumerable: true, get: function () { return pg_1.buildConnectionString; } });
|
|
11
12
|
Object.defineProperty(exports, "getPgPool", { enumerable: true, get: function () { return pg_1.getPgPool; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-cache",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PostgreSQL connection pool LRU cache manager",
|
|
6
6
|
"main": "index.js",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"test:watch": "jest --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@pgpmjs/logger": "^2.
|
|
33
|
-
"@pgpmjs/types": "^2.
|
|
32
|
+
"@pgpmjs/logger": "^2.2.0",
|
|
33
|
+
"@pgpmjs/types": "^2.17.0",
|
|
34
34
|
"lru-cache": "^11.2.4",
|
|
35
35
|
"pg": "^8.17.1",
|
|
36
|
-
"pg-env": "^1.
|
|
36
|
+
"pg-env": "^1.5.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/pg": "^8.16.0",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"connection",
|
|
49
49
|
"constructive"
|
|
50
50
|
],
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b758178b808ce0bf451e86c0bd7e92079155db7c"
|
|
52
52
|
}
|
package/pg.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import pg from 'pg';
|
|
2
2
|
import { PgConfig } from 'pg-env';
|
|
3
|
+
export declare const buildConnectionString: (user: string, password: string, host: string, port: string | number, database: string) => string;
|
|
3
4
|
export declare const getPgPool: (pgConfig: Partial<PgConfig>) => pg.Pool;
|
package/pg.js
CHANGED
|
@@ -3,13 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPgPool = void 0;
|
|
6
|
+
exports.getPgPool = exports.buildConnectionString = void 0;
|
|
7
7
|
const pg_1 = __importDefault(require("pg"));
|
|
8
8
|
const pg_env_1 = require("pg-env");
|
|
9
9
|
const logger_1 = require("@pgpmjs/logger");
|
|
10
10
|
const lru_1 = require("./lru");
|
|
11
11
|
const log = new logger_1.Logger('pg-cache');
|
|
12
|
-
const
|
|
12
|
+
const buildConnectionString = (user, password, host, port, database) => `postgres://${user}:${password}@${host}:${port}/${database}`;
|
|
13
|
+
exports.buildConnectionString = buildConnectionString;
|
|
13
14
|
const getPgPool = (pgConfig) => {
|
|
14
15
|
const config = (0, pg_env_1.getPgEnvOptions)(pgConfig);
|
|
15
16
|
const { user, password, host, port, database, } = config;
|
|
@@ -18,7 +19,7 @@ const getPgPool = (pgConfig) => {
|
|
|
18
19
|
if (cached)
|
|
19
20
|
return cached;
|
|
20
21
|
}
|
|
21
|
-
const connectionString =
|
|
22
|
+
const connectionString = (0, exports.buildConnectionString)(user, password, host, port, database);
|
|
22
23
|
const pgPool = new pg_1.default.Pool({ connectionString });
|
|
23
24
|
/**
|
|
24
25
|
* IMPORTANT: Pool-level error handler for idle connection errors.
|