@opengis/fastify-table 2.0.105 → 2.0.107
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/dist/config.d.ts.map +1 -1
- package/dist/script/adduser +15 -0
- package/dist/script/dump.js +176 -0
- package/dist/script/migrate.js +25 -0
- package/dist/server/migrations/users.sql +1 -1
- package/dist/server/plugins/auth/funcs/verifyPassword.d.ts.map +1 -1
- package/dist/server/plugins/auth/funcs/verifyPassword.js +3 -1
- package/dist/server/plugins/crud/funcs/dataInsert.js +1 -1
- package/dist/server/plugins/crud/funcs/dataUpdate.d.ts.map +1 -1
- package/dist/server/plugins/crud/funcs/dataUpdate.js +7 -4
- package/dist/server/plugins/file/providers/s3/client.d.ts +12 -4
- package/dist/server/plugins/file/providers/s3/client.d.ts.map +1 -1
- package/dist/server/plugins/file/providers/s3/client.js +21 -15
- package/dist/server/plugins/file/providers/s3/funcs/downloadFile.d.ts +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/downloadFile.d.ts.map +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/downloadFile.js +9 -4
- package/dist/server/plugins/file/providers/s3/funcs/fileExists.d.ts +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/fileExists.d.ts.map +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/fileExists.js +13 -10
- package/dist/server/plugins/file/providers/s3/funcs/uploadFile.d.ts +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/uploadFile.d.ts.map +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/uploadFile.js +4 -4
- package/dist/server/plugins/file/providers/s3/funcs/utils/getS3FilePath.d.ts +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/utils/getS3FilePath.d.ts.map +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/utils/getS3FilePath.js +1 -1
- package/dist/server/plugins/file/providers/s3/index.d.ts +1 -1
- package/dist/server/plugins/logger/getLogger.d.ts.map +1 -1
- package/dist/server/plugins/logger/getLogger.js +13 -10
- package/dist/server/plugins/logger/index.d.ts.map +1 -1
- package/dist/server/plugins/logger/index.js +7 -3
- package/dist/server/plugins/pg/funcs/getPG.d.ts.map +1 -1
- package/dist/server/plugins/pg/funcs/getPG.js +1 -0
- package/dist/server/plugins/pg/funcs/getPGAsync.js +1 -1
- package/dist/server/plugins/pg/funcs/init.d.ts +1 -1
- package/dist/server/plugins/pg/funcs/init.d.ts.map +1 -1
- package/dist/server/plugins/pg/funcs/init.js +20 -5
- package/dist/server/plugins/pg/funcs/pool.d.ts.map +1 -1
- package/dist/server/plugins/pg/funcs/pool.js +10 -16
- package/dist/server/plugins/pg/index.d.ts.map +1 -1
- package/dist/server/plugins/pg/index.js +3 -2
- package/dist/server/plugins/redis/funcs/getRedis.d.ts.map +1 -1
- package/dist/server/plugins/redis/funcs/getRedis.js +6 -4
- package/dist/server/plugins/redis/index.d.ts.map +1 -1
- package/dist/server/plugins/redis/index.js +4 -1
- package/dist/server/plugins/sqlite/index.d.ts.map +1 -1
- package/dist/server/plugins/sqlite/index.js +7 -3
- package/dist/server/plugins/table/funcs/getFilter.d.ts +1 -1
- package/dist/server/plugins/table/funcs/getFilter.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getFilter.js +14 -1
- package/dist/server/plugins/table/funcs/getSelectMeta.d.ts +4 -2
- package/dist/server/plugins/table/funcs/getSelectMeta.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getSelectMeta.js +21 -7
- package/dist/server/plugins/table/funcs/gisIRColumn.d.ts +2 -2
- package/dist/server/plugins/table/funcs/gisIRColumn.js +1 -1
- package/dist/server/plugins/util/funcs/unflattenObject.d.ts.map +1 -1
- package/dist/server/plugins/util/funcs/unflattenObject.js +3 -1
- package/dist/server/routes/access/controllers/access.group.d.ts +2 -2
- package/dist/server/routes/access/controllers/access.group.d.ts.map +1 -1
- package/dist/server/routes/access/controllers/access.group.js +0 -1
- package/dist/server/routes/access/controllers/access.group.post.d.ts +2 -2
- package/dist/server/routes/access/controllers/access.group.post.d.ts.map +1 -1
- package/dist/server/routes/access/controllers/access.group.post.js +0 -1
- package/dist/server/routes/auth/controllers/core/registration.d.ts +1 -4
- package/dist/server/routes/auth/controllers/core/registration.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/core/registration.js +28 -9
- package/dist/server/routes/auth/controllers/core/updateUserInfo.js +1 -1
- package/dist/server/routes/auth/controllers/jwt/authorize.js +5 -5
- package/dist/server/routes/auth/controllers/jwt/token.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/jwt/token.js +10 -12
- package/dist/server/routes/cron/controllers/cronApi.d.ts +1 -1
- package/dist/server/routes/cron/controllers/cronApi.d.ts.map +1 -1
- package/dist/server/routes/cron/controllers/cronApi.js +5 -3
- package/dist/server/routes/crud/controllers/insert.d.ts +1 -4
- package/dist/server/routes/crud/controllers/insert.d.ts.map +1 -1
- package/dist/server/routes/crud/controllers/insert.js +24 -16
- package/dist/server/routes/crud/controllers/table.d.ts.map +1 -1
- package/dist/server/routes/crud/controllers/table.js +13 -6
- package/dist/server/routes/crud/controllers/update.d.ts.map +1 -1
- package/dist/server/routes/crud/controllers/update.js +23 -15
- package/dist/server/routes/file/controllers/delete.d.ts +1 -15
- package/dist/server/routes/file/controllers/delete.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/delete.js +13 -20
- package/dist/server/routes/file/controllers/download.d.ts +2 -2
- package/dist/server/routes/file/controllers/download.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/download.js +39 -30
- package/dist/server/routes/file/controllers/files.d.ts +2 -1
- package/dist/server/routes/file/controllers/files.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/files.js +15 -11
- package/dist/server/routes/file/controllers/resize.d.ts +1 -2
- package/dist/server/routes/file/controllers/resize.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/resize.js +17 -6
- package/dist/server/routes/file/controllers/upload.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/upload.js +17 -16
- package/dist/server/routes/file/controllers/uploadImage.d.ts +11 -13
- package/dist/server/routes/file/controllers/uploadImage.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/uploadImage.js +13 -15
- package/dist/server/routes/logger/controllers/logger.file.js +1 -1
- package/dist/server/routes/menu/controllers/interfaces.d.ts +1 -7
- package/dist/server/routes/menu/controllers/interfaces.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/card.d.ts +1 -1
- package/dist/server/routes/table/controllers/card.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/card.js +15 -9
- package/dist/server/routes/table/controllers/filter.d.ts +1 -1
- package/dist/server/routes/table/controllers/filter.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/filter.js +2 -2
- package/dist/server/routes/table/controllers/form.d.ts +1 -1
- package/dist/server/routes/table/controllers/form.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/form.js +8 -5
- package/dist/server/routes/table/controllers/search.d.ts +1 -1
- package/dist/server/routes/table/controllers/search.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/search.js +5 -6
- package/dist/server/routes/table/controllers/suggest.d.ts +1 -1
- package/dist/server/routes/table/controllers/suggest.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/suggest.js +53 -24
- package/dist/server/routes/table/functions/getData.d.ts +1 -1
- package/dist/server/routes/table/functions/getData.d.ts.map +1 -1
- package/dist/server/routes/table/functions/getData.js +60 -34
- package/dist/server/routes/util/controllers/config.d.ts +2 -0
- package/dist/server/routes/util/controllers/config.d.ts.map +1 -0
- package/dist/server/routes/util/controllers/config.js +33 -0
- package/dist/server/routes/util/index.js +2 -2
- package/dist/server/types/core.d.ts +7 -0
- package/dist/server/types/core.d.ts.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -0
- package/package.json +3 -3
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,MAAM,KAA8D,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,MAAM,KAA8D,CAAC;AAqC3E,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
rootDir=`echo $(dirname "$0")`
|
|
3
|
+
echo "$rootDir/passwd"
|
|
4
|
+
|
|
5
|
+
if [ -e "$rootDir/../passwd" ]
|
|
6
|
+
then
|
|
7
|
+
password=`echo -n "$2" | sha1sum | awk '{print $1}'`
|
|
8
|
+
echo "$1:$password"
|
|
9
|
+
echo "$1:$password" >> "$rootDir/../passwd"
|
|
10
|
+
else
|
|
11
|
+
> passwd
|
|
12
|
+
password=`echo -n "$2" | sha1sum | awk '{print $1}'`
|
|
13
|
+
echo "$1:$password"
|
|
14
|
+
echo "$1:$password" > "$rootDir/../passwd"
|
|
15
|
+
fi
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// Вигрузка схеми бд
|
|
2
|
+
// Usage examples:
|
|
3
|
+
// bun .\script\dump.js --table=bpmn.tasks
|
|
4
|
+
// bun .\script\dump.js --schema=bpmn
|
|
5
|
+
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { mkdir, writeFile, rm, rmdir, stat } from 'node:fs/promises';
|
|
9
|
+
|
|
10
|
+
import { config, handlebars, pgClients, getTemplate } from '../utils.js';
|
|
11
|
+
|
|
12
|
+
import { build, teardown } from '../helper.js';
|
|
13
|
+
|
|
14
|
+
const app = build();
|
|
15
|
+
app.addHook('onClose', async () => teardown());
|
|
16
|
+
dumpMigrateSQL();
|
|
17
|
+
// app.close();
|
|
18
|
+
|
|
19
|
+
const debug = false;
|
|
20
|
+
|
|
21
|
+
export default async function dumpMigrateSQL() {
|
|
22
|
+
try {
|
|
23
|
+
// const { database, host, port, user, password } = config.pg;
|
|
24
|
+
|
|
25
|
+
if (!config.pg) {
|
|
26
|
+
console.error('empty config.pg, skip...');
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!Bun.argv[2]) {
|
|
31
|
+
console.error('missing schema / table name, skip...');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const [key, value] = Bun.argv[2].substring(2).split('=');
|
|
35
|
+
const tableName = key === 'table' ? value : null;
|
|
36
|
+
const schemaName = key === 'schema' ? value : value.split('.').shift();
|
|
37
|
+
|
|
38
|
+
const pg = pgClients.client;
|
|
39
|
+
// const pg = await getPGAsync({ database, host, port, user, password });
|
|
40
|
+
await pg.query(`select 1`);
|
|
41
|
+
|
|
42
|
+
const schemaExists = await pg.query(`SELECT 1 FROM information_schema.schemata WHERE schema_name = $1`, [schemaName]).then(el => el.rowCount);
|
|
43
|
+
|
|
44
|
+
if (!schemaExists) {
|
|
45
|
+
console.error('Вказаної схеми не існує', config.pg?.database);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// if (tableName && !pg.pk?.[tableName]) {
|
|
50
|
+
// console.error('Вказаної таблиці не існує', config.pg?.database);
|
|
51
|
+
// return null;
|
|
52
|
+
// }
|
|
53
|
+
|
|
54
|
+
const dump = await schemaItem({
|
|
55
|
+
pg,
|
|
56
|
+
table: tableName,
|
|
57
|
+
schema: schemaName,
|
|
58
|
+
debug,
|
|
59
|
+
is_erd: false
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (debug) {
|
|
63
|
+
console.log(dump);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const filepath = await saveFile(dump, tableName || schemaName);
|
|
68
|
+
console.log('sucess', filepath);
|
|
69
|
+
} catch (err) {
|
|
70
|
+
console.error(err);
|
|
71
|
+
} finally {
|
|
72
|
+
app.close();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function saveFile(data, filename) {
|
|
77
|
+
if (!data) throw new Error(`no data - ${filename}`);
|
|
78
|
+
|
|
79
|
+
const filepath = path.join('log/dump', `${filename}.sql`);
|
|
80
|
+
const fileExists = existsSync(filepath);
|
|
81
|
+
|
|
82
|
+
// overwrite old file
|
|
83
|
+
if (fileExists) {
|
|
84
|
+
const stats = await stat(filepath);
|
|
85
|
+
if (stats.isDirectory()) {
|
|
86
|
+
await rmdir(filepath, { force: true, recursive: true });
|
|
87
|
+
} else {
|
|
88
|
+
await rm(filepath)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
await mkdir(path.dirname(filepath), { recursive: true });
|
|
93
|
+
await writeFile(filepath, Buffer.from(data, 'utf-8'));
|
|
94
|
+
|
|
95
|
+
return filepath;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function schemaItem({
|
|
99
|
+
pg, table, schema, debug
|
|
100
|
+
}) {
|
|
101
|
+
if (!schema && !table) return new Error('param schema is required');
|
|
102
|
+
|
|
103
|
+
const { rows: schemaInfo } = await pg.query(`select c.oid,relname,nspname,obj_description(c.oid) as description,
|
|
104
|
+
(
|
|
105
|
+
select json_agg(row_to_json(q))
|
|
106
|
+
from (
|
|
107
|
+
select
|
|
108
|
+
column_name,
|
|
109
|
+
case
|
|
110
|
+
when data_type='USER-DEFINED' AND udt_name='geometry' THEN 'geometry'
|
|
111
|
+
when data_type='ARRAY' AND udt_name='_text' THEN 'text[]'
|
|
112
|
+
when data_type='ARRAY' AND udt_name='_int4' THEN 'integer[]'
|
|
113
|
+
else data_type
|
|
114
|
+
end as data_type,
|
|
115
|
+
ordinal_position,
|
|
116
|
+
column_default,
|
|
117
|
+
is_nullable,
|
|
118
|
+
case
|
|
119
|
+
when column_name='uid' then 'ідентифікатор автора запису в БД'
|
|
120
|
+
when column_name='cdate' then 'Дата створення запису в БД'
|
|
121
|
+
when column_name='editor_id' then 'Ідентифікатор автора, який останій вніс зміни в запис'
|
|
122
|
+
when column_name='editor_date' then 'Час останії зміни в записі'
|
|
123
|
+
when column_name='files' then 'Системна колонка'
|
|
124
|
+
when column_name='doc_status' then 'Статус документа'
|
|
125
|
+
when column_name='reg_status' then 'Статус реєстрації'
|
|
126
|
+
when column_name='obj_version' then 'Версія запису'
|
|
127
|
+
else col_description(a.attrelid,ordinal_position)
|
|
128
|
+
end as description
|
|
129
|
+
from information_schema.columns col
|
|
130
|
+
LEFT JOIN pg_attribute a ON col.column_name=a.attname and c.oid = a.attrelid
|
|
131
|
+
where col.table_schema=nspname and col.table_name=relname
|
|
132
|
+
)q
|
|
133
|
+
) as columns
|
|
134
|
+
from pg_class c
|
|
135
|
+
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
136
|
+
where ${table ? `nspname||'.'||relname='${table}'` : `'${schema}'=nspname`} and relam=2
|
|
137
|
+
order by nspname,relname`);
|
|
138
|
+
|
|
139
|
+
if (!schemaInfo?.length) throw new Error('invalid params');
|
|
140
|
+
|
|
141
|
+
const { rows: constraints } = await pg.query(`select con.conrelid::regclass as constraint_table, a.column_name,
|
|
142
|
+
con.conname as constraint_name,contype as constraint_type, con.confrelid::regclass as foreign_table,
|
|
143
|
+
con.confupdtype, con.confdeltype, con.confmatchtype, u.column_name as foreign_column from pg_constraint con
|
|
144
|
+
left join pg_class c ON c.oid = con.conrelid
|
|
145
|
+
left join pg_namespace n ON n.oid = c.relnamespace
|
|
146
|
+
left join lateral (
|
|
147
|
+
select string_agg(a.attname,',') as column_name from pg_attribute a
|
|
148
|
+
where con.conrelid = a.attrelid and a.attnum = any(con.conkey) limit 1
|
|
149
|
+
)a on 1=1
|
|
150
|
+
left join lateral (
|
|
151
|
+
select column_name from information_schema.constraint_column_usage u
|
|
152
|
+
where conname=u.constraint_name limit 1
|
|
153
|
+
)u on 1=1
|
|
154
|
+
where ${table ? `conrelid::regclass::text = '${table}'` : `nspname = '${schema}'`}`);
|
|
155
|
+
|
|
156
|
+
// add table constraints, mermaid
|
|
157
|
+
schemaInfo?.forEach((row) => {
|
|
158
|
+
// constraint type to column
|
|
159
|
+
row?.columns?.forEach((col) => {
|
|
160
|
+
const { constraint_type } = constraints?.find((con) => con?.column_name === col?.column_name && con.constraint_table === `${row.nspname}.${row.relname}`) || {};
|
|
161
|
+
Object.assign(col, { constraint_type });
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// table relations
|
|
165
|
+
const tableConstraints = constraints?.filter((el) => el?.constraint_table === `${row.nspname}.${row.relname}`);
|
|
166
|
+
Object.assign(row, { constraints: tableConstraints });
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
if (debug) return schemaInfo;
|
|
170
|
+
|
|
171
|
+
const body = await getTemplate('pt', 'schemaItem.pt');
|
|
172
|
+
|
|
173
|
+
const schemaContent = await handlebars.compile(body?.hbs || 'template not found: schemaItem.pt')({ nspname: schema, rows: schemaInfo, constraints });
|
|
174
|
+
|
|
175
|
+
return schemaContent.replace(/'/g, "'");
|
|
176
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Fastify from 'fastify';
|
|
2
|
+
|
|
3
|
+
import config from '../config.js';
|
|
4
|
+
import plugin from '../index.js';
|
|
5
|
+
|
|
6
|
+
const timeoutMs = +(config.migrationTimeout || 5000);
|
|
7
|
+
|
|
8
|
+
process.env.PORT = process.env.PORT || config.port || 3000;
|
|
9
|
+
|
|
10
|
+
const app = Fastify();
|
|
11
|
+
|
|
12
|
+
app.register(plugin, config);
|
|
13
|
+
|
|
14
|
+
app.listen({ host: '0.0.0.0', port: process.env.PORT }, (err) => {
|
|
15
|
+
console.log(`Server started via port: ${process.env.PORT}`);
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
console.log('Server closed after timeout', timeoutMs);
|
|
18
|
+
app.close();
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}, timeoutMs);
|
|
21
|
+
if (err) {
|
|
22
|
+
console.error('migrations error', err.toString());
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -35,7 +35,7 @@ ALTER TABLE admin.users add CONSTRAINT admin_user_user_rnokpp UNIQUE (user_rnokp
|
|
|
35
35
|
|
|
36
36
|
-- update admin.users set user_type='regular' where user_type not in ('viewer', 'regular','admin','superadmin');
|
|
37
37
|
-- ALTER TABLE admin.users add constraint admin_user_type_check CHECK (user_type=any(array['viewer', 'regular','admin','superadmin']));
|
|
38
|
-
insert into admin.users (uid,login,password,user_type,enabled)values('viewer','viewer','viewer','viewer', false) on conflict (uid) do update set enabled=excluded.enabled;
|
|
38
|
+
insert into admin.users (uid,login,sur_name,password,user_type,enabled)values('viewer','viewer','viewer','viewer','viewer', false) on conflict (uid) do update set enabled=excluded.enabled, sur_name=excluded.sur_name;
|
|
39
39
|
-- update admin.users set enabled=true where uid='viewer';
|
|
40
40
|
|
|
41
41
|
COMMENT ON TABLE admin.users IS 'Користувачі';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyPassword.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/verifyPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWpD,wBAA8B,cAAc,CAAC,EAC3C,EAAE,EACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;;;;;;
|
|
1
|
+
{"version":3,"file":"verifyPassword.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/verifyPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWpD,wBAA8B,cAAc,CAAC,EAC3C,EAAE,EACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;;;;;;eAiCA"}
|
|
@@ -12,7 +12,9 @@ export default async function verifyPassword({ pg, username, password, }) {
|
|
|
12
12
|
if (!password || password === "")
|
|
13
13
|
return { message: "not enough params: password" };
|
|
14
14
|
const query = "select * from admin.users where $1 in (login,email,phone) and enabled limit 1";
|
|
15
|
-
const json = await pg
|
|
15
|
+
const json = await pg
|
|
16
|
+
.query(query, [username])
|
|
17
|
+
.then((el) => el.rows?.[0] || {});
|
|
16
18
|
if (!json)
|
|
17
19
|
return { message: "user not found" };
|
|
18
20
|
let hash = "";
|
|
@@ -103,7 +103,7 @@ export default async function dataInsert({ id, table: table1, referer, data, pg:
|
|
|
103
103
|
uid,
|
|
104
104
|
type: "INSERT",
|
|
105
105
|
});
|
|
106
|
-
if (config.redis) {
|
|
106
|
+
if (config.redis && rclient?.status !== "end") {
|
|
107
107
|
rclient.incr(`pg:${table}:crud`);
|
|
108
108
|
}
|
|
109
109
|
if (!isClient) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataUpdate.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/dataUpdate.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAepD,wBAA8B,UAAU,CAAC,EACvC,KAAK,EACL,SAAS,EACT,OAAO,EACP,EAAE,EACF,IAAI,EACJ,EAAE,EAAE,GAAG,EACP,GAAG,GACJ,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,
|
|
1
|
+
{"version":3,"file":"dataUpdate.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/dataUpdate.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAepD,wBAA8B,UAAU,CAAC,EACvC,KAAK,EACL,SAAS,EACT,OAAO,EACP,EAAE,EACF,IAAI,EACJ,EAAE,EAAE,GAAG,EACP,GAAG,GACJ,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,gBAkPA"}
|
|
@@ -20,11 +20,13 @@ function assignValue(key, i, srid = 4326, columnType = "text") {
|
|
|
20
20
|
return `"${key}"=$${i + 2}`;
|
|
21
21
|
}
|
|
22
22
|
export default async function dataUpdate({ table, tokenData, referer, id, data, pg: pg1, uid, }) {
|
|
23
|
-
if (!data || !table || !id)
|
|
23
|
+
if (!data || !table || !id) {
|
|
24
24
|
return null;
|
|
25
|
+
}
|
|
25
26
|
const pg = pg1 || getPG({ name: "client" });
|
|
26
|
-
if (!pg)
|
|
27
|
+
if (!pg) {
|
|
27
28
|
return null;
|
|
29
|
+
}
|
|
28
30
|
// pg client single transaction support
|
|
29
31
|
if (!pg?.pk && config.pg) {
|
|
30
32
|
pg.options = pgClients.client?.options;
|
|
@@ -34,8 +36,9 @@ export default async function dataUpdate({ table, tokenData, referer, id, data,
|
|
|
34
36
|
pg.pk = pgClients.client?.pk;
|
|
35
37
|
}
|
|
36
38
|
const { columns, pk } = await getMeta({ pg, table });
|
|
37
|
-
if (!columns)
|
|
39
|
+
if (!columns) {
|
|
38
40
|
return null;
|
|
41
|
+
}
|
|
39
42
|
const names = columns.map((el) => el.name);
|
|
40
43
|
const types = columns.reduce((acc, { name, dataTypeID }) => ({
|
|
41
44
|
...acc,
|
|
@@ -167,7 +170,7 @@ export default async function dataUpdate({ table, tokenData, referer, id, data,
|
|
|
167
170
|
uid,
|
|
168
171
|
type: "UPDATE",
|
|
169
172
|
});
|
|
170
|
-
if (config.redis) {
|
|
173
|
+
if (config.redis && rclient?.status !== "end") {
|
|
171
174
|
rclient.incr(`pg:${table}:crud`);
|
|
172
175
|
}
|
|
173
176
|
if (!isClient) {
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const getS3Client: ({ accessKeyId: accessKeyId1, secretAccessKey: secretAccessKey1, user, password, endpoint: endpoint1, host, region, }?: {
|
|
2
|
+
accessKeyId?: string;
|
|
3
|
+
secretAccessKey?: string;
|
|
4
|
+
user?: string;
|
|
5
|
+
password?: string;
|
|
6
|
+
endpoint?: string;
|
|
7
|
+
host?: string;
|
|
8
|
+
region: string;
|
|
9
|
+
}) => any;
|
|
10
|
+
declare const s3Client: any;
|
|
11
|
+
export { getS3Client, s3Client };
|
|
12
|
+
export default s3Client;
|
|
5
13
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/file/providers/s3/client.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/file/providers/s3/client.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,WAAW,GACf,uHAQG;IACD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACE,QA+BpB,CAAC;AAEF,QAAA,MAAM,QAAQ,KAAgB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AAEjC,eAAe,QAAQ,CAAC"}
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { S3Client } from "@aws-sdk/client-s3";
|
|
2
2
|
import { createHash } from "crypto";
|
|
3
|
-
|
|
4
|
-
return createHash("md5").update(string).digest("hex");
|
|
5
|
-
}
|
|
3
|
+
import config from "../.../../../../../../config.js";
|
|
6
4
|
const CLIENT_CACHE = {};
|
|
7
|
-
const getS3Client = ({ accessKeyId, secretAccessKey, user, password, endpoint, host, region = "us-west-2", }) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
const getS3Client = ({ accessKeyId: accessKeyId1, secretAccessKey: secretAccessKey1, user, password, endpoint: endpoint1, host, region = "us-west-2", } = config.s3 || {}) => {
|
|
6
|
+
const accessKeyId = accessKeyId1 || user;
|
|
7
|
+
const endpoint = endpoint1 || host;
|
|
8
|
+
const secretAccessKey = secretAccessKey1 || password;
|
|
9
|
+
if (!accessKeyId || !secretAccessKey || !endpoint) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const uniqueKey = createHash("md5")
|
|
13
|
+
.update(`${accessKeyId}${secretAccessKey}${endpoint}`)
|
|
14
|
+
.digest("hex");
|
|
15
|
+
if (CLIENT_CACHE[uniqueKey]) {
|
|
16
|
+
return CLIENT_CACHE[uniqueKey];
|
|
17
|
+
}
|
|
18
|
+
const client = new S3Client({
|
|
15
19
|
credentials: {
|
|
16
|
-
accessKeyId
|
|
17
|
-
secretAccessKey
|
|
20
|
+
accessKeyId,
|
|
21
|
+
secretAccessKey,
|
|
18
22
|
},
|
|
19
|
-
endpoint
|
|
23
|
+
endpoint,
|
|
20
24
|
forcePathStyle: true,
|
|
21
25
|
region,
|
|
22
26
|
});
|
|
23
27
|
CLIENT_CACHE[uniqueKey] = client;
|
|
24
28
|
return client;
|
|
25
29
|
};
|
|
26
|
-
|
|
30
|
+
const s3Client = getS3Client();
|
|
31
|
+
export { getS3Client, s3Client };
|
|
32
|
+
export default s3Client;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const getFileStream: (s3Settings
|
|
1
|
+
declare const getFileStream: (s3Settings?: Record<string, any>) => (fp: string, options?: Record<string, any>) => Promise<any>;
|
|
2
2
|
export default getFileStream;
|
|
3
3
|
//# sourceMappingURL=downloadFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"downloadFile.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/downloadFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"downloadFile.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/downloadFile.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,aAAa,GAChB,aAAa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAC1B,IAAI,MAAM,EAAE,UAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,iBA2CnD,CAAC;AAEJ,eAAe,aAAa,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { GetObjectCommand } from "@aws-sdk/client-s3";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { createReadStream } from "node:fs";
|
|
4
|
-
import
|
|
4
|
+
import s3Client from "../client.js";
|
|
5
|
+
import config from "../../../../../../config.js";
|
|
5
6
|
import streamToBuffer from "../../utils/streamToBuffer.js";
|
|
6
7
|
// if not found on s3 => fs
|
|
7
8
|
import fsFuncs from "../../fs.js";
|
|
@@ -9,11 +10,11 @@ import getPath from "../../../utils/getPath.js";
|
|
|
9
10
|
import getS3FilePath from "./utils/getS3FilePath.js";
|
|
10
11
|
const getFileStream = (s3Settings) => async (fp, options = {}) => {
|
|
11
12
|
const filepath = getS3FilePath(fp, s3Settings);
|
|
12
|
-
const s3Client = client.getS3Client(s3Settings);
|
|
13
|
-
const bucketName = s3Settings.containerName;
|
|
14
13
|
const bucketParams = {
|
|
15
|
-
Bucket:
|
|
14
|
+
Bucket: (s3Settings || config.s3 || { containerName: "work" })
|
|
15
|
+
.containerName,
|
|
16
16
|
Key: filepath[0] === "/" ? filepath?.slice(1) : filepath,
|
|
17
|
+
Range: options.Range,
|
|
17
18
|
};
|
|
18
19
|
try {
|
|
19
20
|
const data = await s3Client.send(new GetObjectCommand(bucketParams));
|
|
@@ -23,6 +24,10 @@ const getFileStream = (s3Settings) => async (fp, options = {}) => {
|
|
|
23
24
|
return data.Body;
|
|
24
25
|
}
|
|
25
26
|
catch (err) {
|
|
27
|
+
// disable fs fallback for chunked download from s3
|
|
28
|
+
if (options.fallback === false) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
26
31
|
const filepath1 = getPath(fp, options);
|
|
27
32
|
if (!filepath1) {
|
|
28
33
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileExists.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/fileExists.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fileExists.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/fileExists.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,eAAe,GAClB,aAAa,GAAG,MACV,IAAI,GAAG,EAAE,UAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,iBAmBhD,CAAC;AAEJ,eAAe,eAAe,CAAC"}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import { HeadObjectCommand
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { HeadObjectCommand } from "@aws-sdk/client-s3";
|
|
2
|
+
import s3Client from "../client.js";
|
|
3
|
+
import config from "../../../../../../config.js";
|
|
4
|
+
import getPath from "../../../utils/getPath.js";
|
|
5
|
+
import getS3FilePath from "./utils/getS3FilePath.js";
|
|
5
6
|
// if not found on s3 => fs
|
|
6
|
-
import isFileExists from
|
|
7
|
-
const getFileMetadata = (s3Settings) => async (fp) => {
|
|
7
|
+
import isFileExists from "../../../utils/isFileExists.js";
|
|
8
|
+
const getFileMetadata = (s3Settings) => async (fp, options = {}) => {
|
|
8
9
|
const filepath = getS3FilePath(fp, s3Settings);
|
|
9
|
-
const s3Client = client.getS3Client(s3Settings);
|
|
10
|
-
const bucketName = s3Settings.containerName;
|
|
11
10
|
const bucketParams = {
|
|
12
|
-
Bucket:
|
|
13
|
-
|
|
11
|
+
Bucket: (s3Settings || config.s3 || { containerName: "work" })
|
|
12
|
+
.containerName,
|
|
13
|
+
Key: filepath[0] === "/" ? filepath?.slice(1) : filepath,
|
|
14
14
|
};
|
|
15
15
|
try {
|
|
16
16
|
const data = await s3Client.send(new HeadObjectCommand(bucketParams));
|
|
17
17
|
return data;
|
|
18
18
|
}
|
|
19
19
|
catch (err) {
|
|
20
|
+
if (options.fallback === false) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
20
23
|
const filepath1 = getPath(fp);
|
|
21
24
|
return isFileExists(filepath1);
|
|
22
25
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const uploadFile: (s3Settings
|
|
1
|
+
declare const uploadFile: (s3Settings?: any) => (fp: any, data: any) => Promise<import("@aws-sdk/client-s3").CompleteMultipartUploadCommandOutput>;
|
|
2
2
|
export default uploadFile;
|
|
3
3
|
//# sourceMappingURL=uploadFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/uploadFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/uploadFile.ts"],"names":[],"mappings":"AAaA,QAAA,MAAM,UAAU,GAAI,aAAa,GAAG,MAAY,IAAI,GAAG,EAAE,MAAM,GAAG,+EA8BjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Upload } from "@aws-sdk/lib-storage";
|
|
2
|
-
import
|
|
2
|
+
import s3Client from "../client.js";
|
|
3
|
+
import config from "../../../../../../config.js";
|
|
3
4
|
import getValidData from "../../utils/getValidData.js";
|
|
4
5
|
import getDataSize from "../../utils/getDataSize.js";
|
|
5
6
|
import dataTypes from "../../utils/handlers/dataTypes.js";
|
|
@@ -11,10 +12,9 @@ const uploadFile = (s3Settings) => async (fp, data) => {
|
|
|
11
12
|
const size = await getDataSize({ data });
|
|
12
13
|
const type = getMimeType(filepath);
|
|
13
14
|
try {
|
|
14
|
-
const s3Client = client.getS3Client(s3Settings);
|
|
15
|
-
const bucketName = s3Settings.containerName;
|
|
16
15
|
const bucketParams = {
|
|
17
|
-
Bucket:
|
|
16
|
+
Bucket: (s3Settings || config.s3 || { containerName: "work" })
|
|
17
|
+
.containerName,
|
|
18
18
|
Key: filepath,
|
|
19
19
|
ContentLength: size,
|
|
20
20
|
ContentType: type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getS3FilePath.d.ts","sourceRoot":"","sources":["../../../../../../../../server/plugins/file/providers/s3/funcs/utils/getS3FilePath.ts"],"names":[],"mappings":"AAgBA,iBAAS,aAAa,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"getS3FilePath.d.ts","sourceRoot":"","sources":["../../../../../../../../server/plugins/file/providers/s3/funcs/utils/getS3FilePath.ts"],"names":[],"mappings":"AAgBA,iBAAS,aAAa,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,MAAY,UAQrD;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -7,7 +7,7 @@ function getPath(fp, s3Settings) {
|
|
|
7
7
|
}
|
|
8
8
|
return filepath;
|
|
9
9
|
}
|
|
10
|
-
function getS3FilePath(fp, s3Settings) {
|
|
10
|
+
function getS3FilePath(fp, s3Settings = config.s3) {
|
|
11
11
|
const filepath = getPath(fp, s3Settings);
|
|
12
12
|
const unixPath = filepath.replace(/\\/g, "/").split("work/").pop();
|
|
13
13
|
const prefix = !filepath.includes(config.folder) ? config.folder : "";
|
|
@@ -2,6 +2,6 @@ export default function s3Storage(opt: any): {
|
|
|
2
2
|
name: string;
|
|
3
3
|
downloadFile: (fp: string, options?: Record<string, any>) => Promise<any>;
|
|
4
4
|
uploadFile: (fp: any, data: any) => Promise<import("@aws-sdk/client-s3").CompleteMultipartUploadCommandOutput>;
|
|
5
|
-
fileExists: (fp: any) => Promise<any>;
|
|
5
|
+
fileExists: (fp: any, options?: Record<string, any>) => Promise<any>;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLogger.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/getLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,UAAU,cAAe,SAAQ,IAAI,CAAC,MAAM;IAC1C,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAClE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5D;
|
|
1
|
+
{"version":3,"file":"getLogger.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/getLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,UAAU,cAAe,SAAQ,IAAI,CAAC,MAAM;IAC1C,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAClE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5D;AAmDD,QAAA,MAAM,MAAM,EAAE,cAAgD,CAAC;AA+B/D,eAAe,MAAM,CAAC"}
|
|
@@ -9,16 +9,19 @@ import timestampWithTimeZone from "./timestampWithTimeZone.js";
|
|
|
9
9
|
const isServer = process.argv[2];
|
|
10
10
|
const level = process.env.LOG_LEVEL || "info";
|
|
11
11
|
console.log(`log level: ${level}`);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
// skip logging during npx vitest run
|
|
13
|
+
const targets = process.env.VITEST
|
|
14
|
+
? []
|
|
15
|
+
: [
|
|
16
|
+
{
|
|
17
|
+
target: "./createFileStream.js", // path.resolve('utils/createFileStream.js')
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
level: "error",
|
|
21
|
+
target: "pino/file",
|
|
22
|
+
options: { destination: 1 },
|
|
23
|
+
},
|
|
24
|
+
];
|
|
22
25
|
// push trace logs to console (those would not be saved to file)
|
|
23
26
|
if (["trace", "debug"].includes(level)) {
|
|
24
27
|
targets.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;AAyC7E,iBAAe,MAAM,CAAC,OAAO,EAAE,eAAe,iBAwC7C;AACD,eAAe,MAAM,CAAC"}
|
|
@@ -13,12 +13,16 @@ process.on("uncaughtException", (err) => {
|
|
|
13
13
|
});
|
|
14
14
|
// avoid process exit with rejection during client connect at process start
|
|
15
15
|
process.on("unhandledRejection", (err) => {
|
|
16
|
-
if (
|
|
16
|
+
if ([
|
|
17
|
+
"Client was closed and is not queryable",
|
|
18
|
+
"Connection terminated due to connection timeout",
|
|
19
|
+
].includes(err.message)) {
|
|
17
20
|
logger.file("pg", { error: err.message });
|
|
18
|
-
console.warn("Ignored pg connection timeout:", err.toString());
|
|
21
|
+
console.warn("Ignored pg connection timeout / close:", err.toString());
|
|
19
22
|
return;
|
|
20
23
|
}
|
|
21
|
-
if (err.message === "Connection is closed."
|
|
24
|
+
if (err.message === "Connection is closed." ||
|
|
25
|
+
err.message.includes("maxRetriesPerRequest")) {
|
|
22
26
|
logger.file("redis", { error: err.message });
|
|
23
27
|
console.warn("Ignored redis connection close:", err.toString());
|
|
24
28
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPG.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/getPG.ts"],"names":[],"mappings":"AAQA,iBAAS,KAAK,CAAC,KAAK,GAAE,GAAQ,
|
|
1
|
+
{"version":3,"file":"getPG.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/getPG.ts"],"names":[],"mappings":"AAQA,iBAAS,KAAK,CAAC,KAAK,GAAE,GAAQ,OAyD7B;AAMD,eAAe,KAAK,CAAC"}
|
|
@@ -5,6 +5,7 @@ import dblist from "../../../../dblist.js";
|
|
|
5
5
|
import pgClients from "../pgClients.js";
|
|
6
6
|
import getDBParams from "./getDBParams.js";
|
|
7
7
|
function getPG(param = {}) {
|
|
8
|
+
// console.log("config.pg", config.pg, process.env); // ! process.env.VITEST always in uppercase, debug to properly test via npx vitest run
|
|
8
9
|
if (!config.pg)
|
|
9
10
|
return null;
|
|
10
11
|
const dbListParams = dblist.find((el) => el.key === param?.key) ||
|
|
@@ -2,7 +2,7 @@ import init from "./init.js";
|
|
|
2
2
|
import getPG from "./getPG.js";
|
|
3
3
|
async function getPGAsync(param) {
|
|
4
4
|
const client = getPG(param);
|
|
5
|
-
const { host, port, database } = client
|
|
5
|
+
const { host, port, database } = client?.options || {};
|
|
6
6
|
if (client && !client.tlist) {
|
|
7
7
|
// force init
|
|
8
8
|
await init(client).catch((err) => console.warn("PG client init error", host, port, database));
|