@opengis/fastify-table 1.2.36 → 1.2.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.2.36",
3
+ "version": "1.2.37",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -0,0 +1,13 @@
1
+ export default function getDBParams(str) {
2
+ if (typeof str !== 'string') return str;
3
+ if (str.includes('/')) {
4
+ const arr = str.match(/(([A-z_0-9]+):([A-z0-9_]+)@)?([a-z0-9._]+):([0-9]+)(\/([a-z0-9_]+))?/) || [];
5
+ const [, , user, password, host, port, , db] = arr;
6
+ return { name: str, user, password, host, port, db };
7
+ }
8
+ if (str.includes(':')) {
9
+ const [db, port] = str.split(':') || [];
10
+ return { name: str, port, db };
11
+ }
12
+ return { name: str, db: str };
13
+ }
@@ -8,15 +8,7 @@ import config from '../../../../config.js';
8
8
  import dblist from '../../../../dblist.js';
9
9
  import pgClients from '../pgClients.js';
10
10
  import init from './init.js';
11
-
12
- function getDBParams(str) {
13
- if (typeof str === 'string' && !str.includes(':')) {
14
- return { name: str, db: str };
15
- }
16
- const arr = str?.match(/(([A-z_0-9]+):([A-z0-9_]+)@)?([a-z0-9._]+):([0-9]+)(\/([a-z0-9_]+))?/) || [];
17
- const [, , user, password, host, port, , db] = arr;
18
- return { user, password, host, port, db };
19
- }
11
+ import getDBParams from './getDBParams.js';
20
12
 
21
13
  function getPG(param) {
22
14
  const dbListParams = dblist.find(el => el.database === (param?.db || param?.database || param));
@@ -8,15 +8,7 @@ import config from '../../../../config.js';
8
8
  import dblist from '../../../../dblist.js';
9
9
  import pgClients from '../pgClients.js';
10
10
  import init from './init.js';
11
-
12
- function getDBParams(str) {
13
- if (typeof str === 'string' && !str.includes(':')) {
14
- return { name: str, db: str };
15
- }
16
- const arr = str?.match(/(([A-z_0-9]+):([A-z0-9_]+)@)?([a-z0-9._]+):([0-9]+)(\/([a-z0-9_]+))?/) || [];
17
- const [, , user, password, host, port, , db] = arr;
18
- return { user, password, host, port, db };
19
- }
11
+ import getDBParams from './getDBParams.js';
20
12
 
21
13
  async function getPGAsync(param) {
22
14
  const dbListParams = dblist.find(el => el.database === (param?.db || param?.database || param));
package/utils.js CHANGED
@@ -7,6 +7,7 @@ import { handlebars, handlebarsSync } from '@opengis/fastify-hb/utils.js';
7
7
  // pg
8
8
  import getPG from './server/plugins/pg/funcs/getPG.js';
9
9
  import getPGAsync from './server/plugins/pg/funcs/getPGAsync.js';
10
+ import getDBParams from './server/plugins/pg/funcs/getDBParams.js';
10
11
  import initPG from './server/plugins/pg/funcs/init.js';
11
12
  import pgClients from './server/plugins/pg/pgClients.js';
12
13
  import getMeta from './server/plugins/pg/funcs/getMeta.js';
@@ -119,6 +120,7 @@ export {
119
120
  getPG,
120
121
  getPGAsync,
121
122
  pgClients,
123
+ getDBParams,
122
124
 
123
125
  // select
124
126
  getSelectVal,