@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIpD,iBAAe,IAAI,CAAC,MAAM,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIpD,iBAAe,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,iBAuNtC;AAGD,eAAe,IAAI,CAAC"}
|
|
@@ -5,7 +5,17 @@ import getRedis from "../../redis/funcs/getRedis.js";
|
|
|
5
5
|
import logger from "../../logger/getLogger.js";
|
|
6
6
|
const rclient = getRedis({ db: 0 });
|
|
7
7
|
async function init(client) {
|
|
8
|
-
if (!client
|
|
8
|
+
if (!client)
|
|
9
|
+
return;
|
|
10
|
+
// for unit tests
|
|
11
|
+
const options = client.options || {
|
|
12
|
+
database: client.database,
|
|
13
|
+
user: client.user,
|
|
14
|
+
password: client.password,
|
|
15
|
+
port: client.port,
|
|
16
|
+
host: client.host,
|
|
17
|
+
};
|
|
18
|
+
if (!client || !client.query || !client.connect) {
|
|
9
19
|
return;
|
|
10
20
|
}
|
|
11
21
|
const { pgType, pk } = await client
|
|
@@ -72,6 +82,8 @@ async function init(client) {
|
|
|
72
82
|
.then((el) => el.rows || []);
|
|
73
83
|
const relkinds = rows.reduce((acc, curr) => Object.assign(acc, { [curr.tname]: curr.relkind }), {});
|
|
74
84
|
async function query(q, args = []) {
|
|
85
|
+
if (!client)
|
|
86
|
+
throw new Error("empty pg client");
|
|
75
87
|
try {
|
|
76
88
|
const data = await client.query(q, args);
|
|
77
89
|
return data;
|
|
@@ -86,7 +98,7 @@ async function init(client) {
|
|
|
86
98
|
}
|
|
87
99
|
async function querySafe(q, param) {
|
|
88
100
|
const pg1 = new pg.Pool({
|
|
89
|
-
...
|
|
101
|
+
...options,
|
|
90
102
|
statement_timeout: param?.timeout || 100000000,
|
|
91
103
|
});
|
|
92
104
|
try {
|
|
@@ -114,6 +126,8 @@ async function init(client) {
|
|
|
114
126
|
return result;
|
|
115
127
|
}
|
|
116
128
|
async function queryNotice(q, args, cb = () => { }) {
|
|
129
|
+
if (!client)
|
|
130
|
+
throw new Error("empty pg client");
|
|
117
131
|
const clientCb = await client.connect();
|
|
118
132
|
clientCb.on("notice", (e) => {
|
|
119
133
|
cb(e.message);
|
|
@@ -159,6 +173,8 @@ async function init(client) {
|
|
|
159
173
|
return data;
|
|
160
174
|
}
|
|
161
175
|
Object.assign(client, {
|
|
176
|
+
...options,
|
|
177
|
+
options,
|
|
162
178
|
one,
|
|
163
179
|
pgType,
|
|
164
180
|
pk,
|
|
@@ -168,11 +184,10 @@ async function init(client) {
|
|
|
168
184
|
queryNotice,
|
|
169
185
|
querySafe,
|
|
170
186
|
});
|
|
171
|
-
|
|
172
|
-
console.log("New client init finished", client.options?.database);
|
|
187
|
+
console.log("New client init finished", client.database);
|
|
173
188
|
logger.file("pg", {
|
|
174
189
|
message: "client init finished",
|
|
175
|
-
database: client.
|
|
190
|
+
database: client.database,
|
|
176
191
|
});
|
|
177
192
|
}
|
|
178
193
|
// export default client;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/pool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/pool.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,CAAC;yBAE7B,QAAO,GAAQ;AAA/B,wBAgEE"}
|
|
@@ -6,9 +6,8 @@ types.setTypeParser(1114, (stringValue) => stringValue);
|
|
|
6
6
|
import pgClients from "../pgClients.js";
|
|
7
7
|
import init from "./init.js";
|
|
8
8
|
import config from "../../../../config.js";
|
|
9
|
+
config.ready = config.ready || {};
|
|
9
10
|
export const Pools = {};
|
|
10
|
-
const errored = {};
|
|
11
|
-
const inited = {};
|
|
12
11
|
export default (param = {}) => {
|
|
13
12
|
if (!config.pg)
|
|
14
13
|
return null;
|
|
@@ -27,7 +26,7 @@ export default (param = {}) => {
|
|
|
27
26
|
});
|
|
28
27
|
pool.on("error", (err) => {
|
|
29
28
|
console.warn("Unexpected error on idle client", param.database);
|
|
30
|
-
|
|
29
|
+
config.ready[`pg:${param.database}`] = false;
|
|
31
30
|
logger.file("pg", {
|
|
32
31
|
error: err.toString(),
|
|
33
32
|
database: param.database,
|
|
@@ -36,14 +35,14 @@ export default (param = {}) => {
|
|
|
36
35
|
console.warn("Unexpected error on idle client details:", err.toString(), err.stack);
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
|
-
pool.on("connect", (
|
|
38
|
+
pool.on("connect", () => {
|
|
40
39
|
// skip auto drops and reconnects handled by pg internally
|
|
41
|
-
if (!
|
|
40
|
+
if (!config.ready[`pg:${param.database}`]) {
|
|
42
41
|
logger.file("pg", {
|
|
43
42
|
message: "client connected",
|
|
44
43
|
database: param.database,
|
|
45
44
|
});
|
|
46
|
-
|
|
45
|
+
config.ready[`pg:${param.database}`] = true;
|
|
47
46
|
}
|
|
48
47
|
if (config.trace) {
|
|
49
48
|
console.log("PG client connected", param.database);
|
|
@@ -52,17 +51,12 @@ export default (param = {}) => {
|
|
|
52
51
|
if (pgClients[name] && !pgClients[name]?.tlist) {
|
|
53
52
|
init(Pools[name]);
|
|
54
53
|
}
|
|
55
|
-
Pools[name] =
|
|
54
|
+
Pools[name] = pool;
|
|
56
55
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
console.log("PG client acquired", param.database);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
pool.on("remove", () => {
|
|
63
|
-
if (config.trace) {
|
|
56
|
+
if (config.trace) {
|
|
57
|
+
pool.on("remove", () => {
|
|
64
58
|
console.log("PG Client removed from the pool.", param.database);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
67
61
|
return pool;
|
|
68
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/pg/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/pg/index.ts"],"names":[],"mappings":"AAgCA,iBAAS,MAAM,CAAC,OAAO,EAAE,GAAG,QAwB3B;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -3,8 +3,9 @@ import pgClients from "./pgClients.js";
|
|
|
3
3
|
import getPGAsync from "./funcs/getPGAsync.js";
|
|
4
4
|
import logger from "../logger/getLogger.js";
|
|
5
5
|
function close() {
|
|
6
|
-
Object.keys(pgClients).forEach((
|
|
7
|
-
|
|
6
|
+
Object.keys(pgClients).forEach((key) => {
|
|
7
|
+
console.log("Closing pg client", key);
|
|
8
|
+
pgClients[key].end();
|
|
8
9
|
});
|
|
9
10
|
}
|
|
10
11
|
async function getHeadersPG(req) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRedis.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/redis/funcs/getRedis.ts"],"names":[],"mappings":"AAQA,iBAAS,QAAQ,CACf,EACE,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,
|
|
1
|
+
{"version":3,"file":"getRedis.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/redis/funcs/getRedis.ts"],"names":[],"mappings":"AAQA,iBAAS,QAAQ,CACf,EACE,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,WAAmB,EACnB,aAA8D,EAC9D,kBAAyB,EACzB,WAAkB,EAClB,cAAqB,EACrB,oBAAwB,GACzB,GAAE;IACD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACnB,OA6Cd;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -3,10 +3,15 @@ import config from "../../../../config.js";
|
|
|
3
3
|
import logger from "../../logger/getLogger.js";
|
|
4
4
|
import redisClients from "./redisClients.js";
|
|
5
5
|
config.ready = config.ready || {};
|
|
6
|
-
function getRedis({ db, host, port, closeClient =
|
|
6
|
+
function getRedis({ db, host, port, closeClient = false, retryStrategy = (times) => Math.min(times * 500, 5000), enableOfflineQueue = true, lazyConnect = true, connectTimeout = 2000, maxRetriesPerRequest = 1, } = { db: 0 }) {
|
|
7
7
|
if (!config.redis && !host)
|
|
8
8
|
return null;
|
|
9
9
|
const key = host || port ? [host, port, db].join("-") : db;
|
|
10
|
+
// try to reconnect after connection error / disconnect
|
|
11
|
+
if (redisClients[key]?.status === "end" &&
|
|
12
|
+
typeof redisClients[key].connect === "function") {
|
|
13
|
+
redisClients[key].connect();
|
|
14
|
+
}
|
|
10
15
|
if (redisClients[key]) {
|
|
11
16
|
return redisClients[key];
|
|
12
17
|
}
|
|
@@ -30,9 +35,6 @@ function getRedis({ db, host, port, closeClient = true, retryStrategy = () => {
|
|
|
30
35
|
redisClients[key].on("error", (err) => {
|
|
31
36
|
console.warn("Ignored redis error:", err.message);
|
|
32
37
|
logger.file("redis", { error: err.toString() });
|
|
33
|
-
if (err.code === "ETIMEDOUT") {
|
|
34
|
-
// redisClients[key].disconnect();
|
|
35
|
-
}
|
|
36
38
|
});
|
|
37
39
|
console.log("redis connected", db, host, port);
|
|
38
40
|
return redisClients[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/redis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/redis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAW/C,iBAAe,MAAM,CAAC,OAAO,EAAE,eAAe,iBAE7C;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import redisClients from "./funcs/redisClients.js";
|
|
2
2
|
function close() {
|
|
3
|
-
Object.keys(redisClients).forEach((key) =>
|
|
3
|
+
Object.keys(redisClients).forEach((key) => {
|
|
4
|
+
console.log("Closing redis client", key);
|
|
5
|
+
redisClients[key].quit();
|
|
6
|
+
});
|
|
4
7
|
}
|
|
5
8
|
async function plugin(fastify) {
|
|
6
9
|
fastify.addHook("onClose", close);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/sqlite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/sqlite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAa1C,iBAAe,QAAQ,CAAC,GAAG,EAAE,eAAe,iBAE3C;;AAED,wBAA4B"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import fp from "fastify-plugin";
|
|
2
2
|
import sqliteClients from "./sqliteClients.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
function close() {
|
|
4
|
+
Object.keys(sqliteClients).forEach((key) => {
|
|
5
|
+
console.log("Closing sqlite client", key);
|
|
6
|
+
sqliteClients[key].close();
|
|
6
7
|
});
|
|
7
8
|
}
|
|
9
|
+
async function dbPlugin(app) {
|
|
10
|
+
app.addHook("onClose", close);
|
|
11
|
+
}
|
|
8
12
|
export default fp(dbPlugin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFilter.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getFilter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"getFilter.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getFilter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAmBzD,wBAA8B,SAAS,CACrC,EACE,EAAqB,EACrB,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,IAAI,GACL,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B,EACD,KAAK,CAAC,EAAE,GAAG,gBAoBZ"}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import routeFilter from "../../../routes/table/controllers/filter.js";
|
|
2
2
|
import pgClients from "../../pg/pgClients.js";
|
|
3
|
+
const reply1 = {
|
|
4
|
+
response: {},
|
|
5
|
+
// redirect: (txt) => txt,
|
|
6
|
+
redirect: (txt) => Object.assign(reply1.response, {
|
|
7
|
+
body: txt,
|
|
8
|
+
statusCode: reply1.response.statusCode || 200,
|
|
9
|
+
}),
|
|
10
|
+
status: (statusCode) => {
|
|
11
|
+
Object.assign(reply1.response, { status: statusCode });
|
|
12
|
+
return reply1;
|
|
13
|
+
},
|
|
14
|
+
send: (txt) => Object.assign(reply1.response, txt),
|
|
15
|
+
};
|
|
3
16
|
export default async function getFilter({ pg = pgClients.client, table, filter, custom, state, search, user, }, reply) {
|
|
4
17
|
const params = { table };
|
|
5
18
|
const query = {
|
|
@@ -13,6 +26,6 @@ export default async function getFilter({ pg = pgClients.client, table, filter,
|
|
|
13
26
|
params,
|
|
14
27
|
query,
|
|
15
28
|
user,
|
|
16
|
-
}, reply, 1);
|
|
29
|
+
}, reply || reply1, 1);
|
|
17
30
|
return result;
|
|
18
31
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ExtendedPG } from "../../../types/core.js";
|
|
2
|
-
export default function getSelectMeta({ name,
|
|
2
|
+
export default function getSelectMeta({ name, startsWith, key, nocache, parent, pg, }: {
|
|
3
3
|
name: string;
|
|
4
|
-
|
|
4
|
+
startsWith?: boolean;
|
|
5
|
+
key?: string;
|
|
5
6
|
nocache?: any;
|
|
6
7
|
parent?: string;
|
|
8
|
+
pg?: ExtendedPG;
|
|
7
9
|
}): Promise<any>;
|
|
8
10
|
//# sourceMappingURL=getSelectMeta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelectMeta.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelectMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWzD,wBAA8B,aAAa,CAAC,EAC1C,IAAI,EACJ,
|
|
1
|
+
{"version":3,"file":"getSelectMeta.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelectMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWzD,wBAA8B,aAAa,CAAC,EAC1C,IAAI,EACJ,UAAU,EACV,GAAG,EACH,OAAO,EACP,MAAM,EACN,EAAqB,GACtB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB,gBA4GA"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import logger from "../../logger/getLogger.js";
|
|
2
2
|
import autoIndex from "../../pg/funcs/autoIndex.js";
|
|
3
|
-
import
|
|
3
|
+
import getPGAsync from "../../pg/funcs/getPGAsync.js";
|
|
4
4
|
import pgClients from "../../pg/pgClients.js";
|
|
5
5
|
import getSelect from "./getSelect.js";
|
|
6
6
|
const limit = 50;
|
|
7
7
|
const selectMeta = {};
|
|
8
|
-
export default async function getSelectMeta({ name, pg = pgClients.client,
|
|
9
|
-
if (selectMeta[name] && !nocache)
|
|
8
|
+
export default async function getSelectMeta({ name, startsWith, key, nocache, parent, pg = pgClients.client, }) {
|
|
9
|
+
if (selectMeta[name] && !startsWith && !nocache)
|
|
10
10
|
return selectMeta[name];
|
|
11
|
+
if (selectMeta[name] && startsWith && key && !nocache) {
|
|
12
|
+
const searchQuery = `(${selectMeta[name].searchColumn
|
|
13
|
+
.split(",")
|
|
14
|
+
.map((el) => `left(lower("${el}"),${key.length}) = $1`)
|
|
15
|
+
.join(" or ")})`;
|
|
16
|
+
return { ...selectMeta[name], searchQuery };
|
|
17
|
+
}
|
|
11
18
|
const cls = await getSelect(name, pg, nocache);
|
|
12
19
|
const db = typeof cls?.db === "string" ? { database: cls.db } : cls?.db;
|
|
13
|
-
const pg1 = cls?.db ?
|
|
14
|
-
if (!pg1?.pk)
|
|
15
|
-
await pg1.init();
|
|
20
|
+
const pg1 = cls?.db ? await getPGAsync(db) : pg;
|
|
16
21
|
if (!cls)
|
|
17
22
|
return null;
|
|
18
23
|
if (cls.arr)
|
|
@@ -52,12 +57,13 @@ export default async function getSelectMeta({ name, pg = pgClients.client, nocac
|
|
|
52
57
|
(dataOrigin.fields.find((el) => el.name === "search")
|
|
53
58
|
? "search"
|
|
54
59
|
: dataOrigin1.fields[1].name);
|
|
60
|
+
// by default - search by like %value%
|
|
55
61
|
const searchQuery = `(${searchColumn
|
|
56
62
|
.split(",")
|
|
57
63
|
.map((el) => `lower("${el}") ~ $1 `)
|
|
58
64
|
.join(" or ")})`;
|
|
59
|
-
// console.log(dataOrigin1.fields.map((el) => el.name).join(','));
|
|
60
65
|
const data = {
|
|
66
|
+
searchColumn,
|
|
61
67
|
minLength: cls.minLength,
|
|
62
68
|
limit: cls.limit,
|
|
63
69
|
type: type.join(","),
|
|
@@ -73,5 +79,13 @@ export default async function getSelectMeta({ name, pg = pgClients.client, nocac
|
|
|
73
79
|
time: new Date().toISOString(),
|
|
74
80
|
};
|
|
75
81
|
selectMeta[name] = data;
|
|
82
|
+
// on demand - search by "start with these characters"
|
|
83
|
+
if (startsWith && key?.length) {
|
|
84
|
+
const searchQuery = `(${selectMeta[name].searchColumn
|
|
85
|
+
.split(",")
|
|
86
|
+
.map((el) => `left(lower("${el}"),${key.length}) = $1`)
|
|
87
|
+
.join(" or ")})`;
|
|
88
|
+
return { ...data, searchQuery };
|
|
89
|
+
}
|
|
76
90
|
return data;
|
|
77
91
|
}
|
|
@@ -28,7 +28,7 @@ export default function gisIRColumn({ pg, layer, column, sql, query, filter, sta
|
|
|
28
28
|
} | {
|
|
29
29
|
count: any;
|
|
30
30
|
sql: string | undefined;
|
|
31
|
-
rows: any
|
|
31
|
+
rows: any;
|
|
32
32
|
error?: undefined;
|
|
33
33
|
status?: undefined;
|
|
34
34
|
message?: undefined;
|
|
@@ -37,7 +37,7 @@ export default function gisIRColumn({ pg, layer, column, sql, query, filter, sta
|
|
|
37
37
|
time: number;
|
|
38
38
|
count: any;
|
|
39
39
|
sql: string | undefined;
|
|
40
|
-
rows: any
|
|
40
|
+
rows: any;
|
|
41
41
|
error?: undefined;
|
|
42
42
|
status?: undefined;
|
|
43
43
|
message?: undefined;
|
|
@@ -19,7 +19,7 @@ export default async function gisIRColumn({ pg = pgClients.client, layer, column
|
|
|
19
19
|
const { tlist } = await pg
|
|
20
20
|
.query(`select array_agg((select nspname from pg_namespace where oid=relnamespace)||'.'||relname) tlist from pg_class
|
|
21
21
|
where relkind in ('r','v','m')`)
|
|
22
|
-
.then((el) => el.rows[0]);
|
|
22
|
+
.then((el) => el.rows?.[0] || {});
|
|
23
23
|
const tableName = body?.table || layer;
|
|
24
24
|
if (!tlist.includes(tableName))
|
|
25
25
|
return { error: `table not found: ${tableName}`, status: 400 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unflattenObject.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/util/funcs/unflattenObject.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"unflattenObject.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/util/funcs/unflattenObject.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,GAAG,MA4CnD"}
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
export default function unflattenObject(flatObj) {
|
|
6
6
|
const res = Object.keys(flatObj || {}).reduce((acc, key) => {
|
|
7
7
|
const keys = key.split(".");
|
|
8
|
-
keys.reduce((nestedObj,
|
|
8
|
+
keys.reduce((nestedObj, part1, index) => {
|
|
9
|
+
// ! prevent npx vitest run from upper case -ing env variables
|
|
10
|
+
const part = process.env.VITEST ? part1.toLowerCase() : part1;
|
|
9
11
|
if (index === keys.length - 1) {
|
|
10
12
|
// json array
|
|
11
13
|
if (typeof flatObj[key] === "string" &&
|
|
@@ -8,7 +8,7 @@ export default function accessGroup({ pg, params, user, unittest, }: {
|
|
|
8
8
|
user: Record<string, any>;
|
|
9
9
|
unittest?: any;
|
|
10
10
|
}, reply: FastifyReply): Promise<{
|
|
11
|
-
routes: any
|
|
12
|
-
users: any
|
|
11
|
+
routes: any;
|
|
12
|
+
users: any;
|
|
13
13
|
}>;
|
|
14
14
|
//# sourceMappingURL=access.group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.group.d.ts","sourceRoot":"","sources":["../../../../../server/routes/access/controllers/access.group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,wBAA8B,WAAW,CACvC,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,EACT,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,EAED,KAAK,EAAE,YAAY;;;
|
|
1
|
+
{"version":3,"file":"access.group.d.ts","sourceRoot":"","sources":["../../../../../server/routes/access/controllers/access.group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,wBAA8B,WAAW,CACvC,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,EACT,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,EAED,KAAK,EAAE,YAAY;;;GA+BpB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { pgClients, getAdminAccess } from "../../../../utils.js";
|
|
2
2
|
export default async function accessGroup({ pg = pgClients.client, params, user = {}, unittest, }, reply) {
|
|
3
|
-
debugger;
|
|
4
3
|
if (!params?.id) {
|
|
5
4
|
return reply.status(400).send("not enough params: id");
|
|
6
5
|
}
|
|
@@ -9,7 +9,7 @@ export default function accessGroupPost({ pg, params, user, body, unittest, }: {
|
|
|
9
9
|
body: Record<string, any>;
|
|
10
10
|
unittest?: any;
|
|
11
11
|
}, reply: FastifyReply): Promise<{
|
|
12
|
-
routes: any
|
|
13
|
-
users: any
|
|
12
|
+
routes: any;
|
|
13
|
+
users: any;
|
|
14
14
|
}>;
|
|
15
15
|
//# sourceMappingURL=access.group.post.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.group.post.d.ts","sourceRoot":"","sources":["../../../../../server/routes/access/controllers/access.group.post.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzD,wBAA8B,eAAe,CAC3C,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,EACT,IAAS,EACT,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,EACD,KAAK,EAAE,YAAY;;;
|
|
1
|
+
{"version":3,"file":"access.group.post.d.ts","sourceRoot":"","sources":["../../../../../server/routes/access/controllers/access.group.post.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzD,wBAA8B,eAAe,CAC3C,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,EACT,IAAS,EACT,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,EACD,KAAK,EAAE,YAAY;;;GA2FpB"}
|
|
@@ -12,7 +12,6 @@ export default async function accessGroupPost({ pg = pgClients.client, params, u
|
|
|
12
12
|
}
|
|
13
13
|
const { users = [], routes = [] } = body;
|
|
14
14
|
if (!routes?.length) {
|
|
15
|
-
// return { message: 'not enough params: users / routes', status: 400 };
|
|
16
15
|
await pg.query("delete from admin.role_access where role_id=$1", [id]);
|
|
17
16
|
if (!users?.length) {
|
|
18
17
|
return reply.status(200).send({ id, routes });
|
|
@@ -17,8 +17,5 @@ import { FastifyReply } from "fastify";
|
|
|
17
17
|
* @returns {String|Object} error Опис помилки
|
|
18
18
|
* @returns {String|Object} message Повідомлення про успішну реєстрацію
|
|
19
19
|
*/
|
|
20
|
-
export default function registration({ pg, body }: any, reply: FastifyReply): Promise<
|
|
21
|
-
message: string;
|
|
22
|
-
status: number;
|
|
23
|
-
}>;
|
|
20
|
+
export default function registration({ method, pg, body }: any, reply: FastifyReply): Promise<never>;
|
|
24
21
|
//# sourceMappingURL=registration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/core/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAWvC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAA8B,YAAY,CACxC,EAAE,EAAqB,EAAE,IAAS,EAAE,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/core/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAWvC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAA8B,YAAY,CACxC,EAAE,MAAM,EAAE,EAAqB,EAAE,IAAS,EAAE,EAAE,GAAG,EACjD,KAAK,EAAE,YAAY,kBAoHpB"}
|
|
@@ -22,26 +22,41 @@ import pgClients from "../../../../plugins/pg/pgClients.js";
|
|
|
22
22
|
* @returns {String|Object} error Опис помилки
|
|
23
23
|
* @returns {String|Object} message Повідомлення про успішну реєстрацію
|
|
24
24
|
*/
|
|
25
|
-
export default async function registration({ pg = pgClients.client, body = {} }, reply) {
|
|
25
|
+
export default async function registration({ method, pg = pgClients.client, body = {} }, reply) {
|
|
26
26
|
const { password, email } = body;
|
|
27
27
|
if (!password || (!email && !body.login)) {
|
|
28
|
-
return
|
|
28
|
+
return reply.status(400).send({
|
|
29
|
+
error: "Недостатньо параметрів",
|
|
30
|
+
code: 400,
|
|
31
|
+
});
|
|
29
32
|
}
|
|
30
33
|
const regularExp = /^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,6}$/;
|
|
31
34
|
if (email && !regularExp.test(email)) {
|
|
32
|
-
return
|
|
35
|
+
return reply.status(400).send({
|
|
36
|
+
error: "Параметр E-mail невалідний",
|
|
37
|
+
code: 400,
|
|
38
|
+
});
|
|
33
39
|
}
|
|
34
40
|
if (body?.first_name &&
|
|
35
41
|
!/[А-Яа-яA-Za-zёЁЇїІіЄєҐґ '-]+/.test(body?.first_name)) {
|
|
36
|
-
return
|
|
42
|
+
return reply.status(400).send({
|
|
43
|
+
error: "Параметр Ім'я невалідний",
|
|
44
|
+
code: 400,
|
|
45
|
+
});
|
|
37
46
|
}
|
|
38
47
|
if (body?.last_name &&
|
|
39
48
|
!/[А-Яа-яA-Za-zёЁЇїІіЄєҐґ '-]+/.test(body?.last_name)) {
|
|
40
|
-
return
|
|
49
|
+
return reply.status(400).send({
|
|
50
|
+
error: "Параметр Прізвище невалідний",
|
|
51
|
+
code: 400,
|
|
52
|
+
});
|
|
41
53
|
}
|
|
42
54
|
if (body?.phone &&
|
|
43
55
|
!/^\+\d{3}\s?\d{2}\s?\d{3}\s?\d{2}\s?\d{2}$/.test(body?.phone)) {
|
|
44
|
-
return
|
|
56
|
+
return reply.status(400).send({
|
|
57
|
+
error: "Параметр Телефон невалідний",
|
|
58
|
+
code: 400,
|
|
59
|
+
});
|
|
45
60
|
}
|
|
46
61
|
const login = body.login || email;
|
|
47
62
|
const data = {
|
|
@@ -63,7 +78,7 @@ export default async function registration({ pg = pgClients.client, body = {} },
|
|
|
63
78
|
const txt = !body.login
|
|
64
79
|
? "Даний адрес електронної пошти вже прив'язаний до іншого облікового запису"
|
|
65
80
|
: "Даний логін вже використовується";
|
|
66
|
-
return {
|
|
81
|
+
return reply.status(409).send({ error: txt, code: 409 });
|
|
67
82
|
}
|
|
68
83
|
if (pg.pk?.["crm_acc.crm_contact"]) {
|
|
69
84
|
// insert crm contact
|
|
@@ -74,7 +89,7 @@ export default async function registration({ pg = pgClients.client, body = {} },
|
|
|
74
89
|
const txt = !body.login
|
|
75
90
|
? "Користувача за даною адресою вже зареєстровано"
|
|
76
91
|
: "Даний логін вже використовується";
|
|
77
|
-
return {
|
|
92
|
+
return reply.status(409).send({ error: txt, code: 409 });
|
|
78
93
|
}
|
|
79
94
|
await dataInsert({ pg, table: "crm_acc.crm_contact", data });
|
|
80
95
|
const { uid } = await pg
|
|
@@ -92,5 +107,9 @@ export default async function registration({ pg = pgClients.client, body = {} },
|
|
|
92
107
|
data,
|
|
93
108
|
});
|
|
94
109
|
}
|
|
95
|
-
|
|
110
|
+
const redirectUrl = config.auth?.link?.core?.login || config?.auth?.redirect || "/login";
|
|
111
|
+
if (method === "POST") {
|
|
112
|
+
return reply.status(200).send({ msg: "registration success", redirectUrl });
|
|
113
|
+
}
|
|
114
|
+
return reply.redirect(redirectUrl);
|
|
96
115
|
}
|
|
@@ -3,7 +3,7 @@ import dataUpdate from "../../../../plugins/crud/funcs/dataUpdate.js";
|
|
|
3
3
|
export default async function updateUserInfo(req, reply) {
|
|
4
4
|
const { body: payload, pg = pgClients.client } = req;
|
|
5
5
|
if (!req.user?.uid) {
|
|
6
|
-
return reply.code(401).send({
|
|
6
|
+
return reply.code(401).send({ error: "Unauthorized", code: 401 });
|
|
7
7
|
}
|
|
8
8
|
const userInfo = Object.fromEntries(Object.entries(payload || {}).filter(([key]) => !["salt", "user_type"].includes(key)));
|
|
9
9
|
const result = await dataUpdate({
|
|
@@ -19,12 +19,12 @@ export default async function authorize(req, reply) {
|
|
|
19
19
|
if (response_type !== "code") {
|
|
20
20
|
return reply
|
|
21
21
|
.code(400)
|
|
22
|
-
.send({
|
|
22
|
+
.send({ error: "unsupported response_type", code: 400 });
|
|
23
23
|
}
|
|
24
24
|
if (!client_id) {
|
|
25
25
|
return reply
|
|
26
26
|
.code(400)
|
|
27
|
-
.send({
|
|
27
|
+
.send({ error: "not enough query params: client_id", code: 400 });
|
|
28
28
|
}
|
|
29
29
|
const q = `select owner_user_id, client_secret_hash, redirect_uris from oauth.clients where client_id=$1 and token_endpoint_auth_method=$2 and ${scope ? "$1=any(scopes)" : "1=1"}`;
|
|
30
30
|
const { owner_user_id: userId, client_secret_hash: secret, redirect_uris = [], } = pg.pk?.["oauth.clients"]
|
|
@@ -33,12 +33,12 @@ export default async function authorize(req, reply) {
|
|
|
33
33
|
.then((el) => el.rows?.[0] || {})
|
|
34
34
|
: {};
|
|
35
35
|
if (!userId) {
|
|
36
|
-
return reply.code(400).send({
|
|
36
|
+
return reply.code(400).send({ error: "invalid client id", code: 400 });
|
|
37
37
|
}
|
|
38
38
|
if (redirect_uri &&
|
|
39
39
|
Array.isArray(redirect_uris) &&
|
|
40
40
|
!redirect_uris.includes(redirect_uri)) {
|
|
41
|
-
return reply.code(400).send({
|
|
41
|
+
return reply.code(400).send({ error: "invalid redirect_uri", code: 400 });
|
|
42
42
|
}
|
|
43
43
|
const user = pg.pk?.["admin.users"]
|
|
44
44
|
? await pg
|
|
@@ -48,7 +48,7 @@ export default async function authorize(req, reply) {
|
|
|
48
48
|
.then((el) => el.rows[0])
|
|
49
49
|
: null;
|
|
50
50
|
if (!user) {
|
|
51
|
-
return reply.code(404).send({
|
|
51
|
+
return reply.code(404).send({ error: "user not found", code: 404 });
|
|
52
52
|
}
|
|
53
53
|
const href1 = await authorizeUser(user, req, "jwt", expireMsec);
|
|
54
54
|
// Generate authorization code
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/jwt/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAmB5D,wBAA8B,UAAU,CACtC,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/jwt/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAmB5D,wBAA8B,UAAU,CACtC,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,YAAY,kBAmHpB"}
|