pg-cache 2.1.0 → 3.0.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 CHANGED
@@ -1,3 +1,3 @@
1
1
  // Main exports from pg-cache package
2
2
  export { close, pgCache, PgPoolCacheManager, teardownPgPools } from './lru';
3
- export { getPgPool } from './pg';
3
+ export { buildConnectionString, getPgPool } from './pg';
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 getDbString = (user, password, host, port, database) => `postgres://${user}:${password}@${host}:${port}/${database}`;
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 = getDbString(user, password, host, port, database);
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
@@ -1,3 +1,3 @@
1
1
  export { close, pgCache, PgPoolCacheManager, teardownPgPools } from './lru';
2
- export { getPgPool } from './pg';
2
+ export { buildConnectionString, getPgPool } from './pg';
3
3
  export type { PoolCleanupCallback } from './lru';
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": "2.1.0",
3
+ "version": "3.0.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PostgreSQL connection pool LRU cache manager",
6
6
  "main": "index.js",
@@ -48,5 +48,5 @@
48
48
  "connection",
49
49
  "constructive"
50
50
  ],
51
- "gitHead": "048188f6b43ffaa6146e7694b2b0d35d34cb2945"
51
+ "gitHead": "b2daeefe49cdefb3d01ea63cf778fb9b847ab5fe"
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 getDbString = (user, password, host, port, database) => `postgres://${user}:${password}@${host}:${port}/${database}`;
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 = getDbString(user, password, host, port, database);
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.