@opengis/fastify-table 1.1.135 → 1.1.136
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/README.md +86 -86
- package/index.js +78 -78
- package/package.json +1 -1
- package/server/migrations/0.sql +80 -80
- package/server/migrations/cls.sql +39 -39
- package/server/migrations/context.sql +134 -95
- package/server/migrations/properties.sql +144 -144
- package/server/migrations/users.sql +173 -173
- package/server/plugins/cron/funcs/addCron.js +130 -130
- package/server/plugins/cron/index.js +6 -6
- package/server/plugins/crud/funcs/dataDelete.js +23 -23
- package/server/plugins/crud/funcs/dataInsert.js +45 -45
- package/server/plugins/crud/funcs/dataUpdate.js +65 -65
- package/server/plugins/crud/funcs/getOpt.js +13 -13
- package/server/plugins/crud/funcs/setOpt.js +21 -21
- package/server/plugins/crud/funcs/setToken.js +44 -44
- package/server/plugins/crud/funcs/utils/getFolder.js +10 -10
- package/server/plugins/crud/funcs/utils/logChanges.js +62 -62
- package/server/plugins/crud/index.js +23 -23
- package/server/plugins/hook/index.js +8 -8
- package/server/plugins/logger/errorStatus.js +19 -19
- package/server/plugins/logger/index.js +21 -21
- package/server/plugins/migration/funcs/exec.migrations.js +86 -86
- package/server/plugins/migration/index.js +7 -7
- package/server/plugins/pg/pgClients.js +21 -21
- package/server/plugins/policy/index.js +12 -12
- package/server/plugins/policy/sqlInjection.js +33 -33
- package/server/plugins/redis/client.js +8 -8
- package/server/plugins/redis/funcs/redisClients.js +3 -3
- package/server/plugins/redis/index.js +17 -17
- package/server/plugins/table/funcs/addTemplateDir.js +8 -8
- package/server/plugins/table/funcs/getFilterSQL/index.js +96 -96
- package/server/plugins/table/funcs/getFilterSQL/util/formatValue.js +171 -171
- package/server/plugins/table/funcs/getFilterSQL/util/getCustomQuery.js +13 -13
- package/server/plugins/table/funcs/getFilterSQL/util/getFilterQuery.js +66 -66
- package/server/plugins/table/funcs/getFilterSQL/util/getOptimizedQuery.js +12 -12
- package/server/plugins/table/funcs/getFilterSQL/util/getTableSql.js +34 -34
- package/server/plugins/table/funcs/getSelect.js +30 -29
- package/server/plugins/table/funcs/getTemplates.js +19 -19
- package/server/plugins/table/funcs/gisIRColumn.js +82 -82
- package/server/plugins/table/funcs/loadTemplate.js +1 -1
- package/server/plugins/table/funcs/loadTemplatePath.js +1 -1
- package/server/plugins/table/funcs/metaFormat/getSelectVal.js +50 -50
- package/server/plugins/table/funcs/metaFormat/index.js +45 -45
- package/server/plugins/table/funcs/userTemplateDir.js +1 -1
- package/server/plugins/table/index.js +13 -13
- package/server/plugins/util/index.js +7 -7
- package/server/routes/cron/index.js +14 -14
- package/server/routes/crud/controllers/deleteCrud.js +36 -36
- package/server/routes/crud/controllers/table.js +91 -91
- package/server/routes/logger/controllers/logger.file.js +92 -92
- package/server/routes/logger/controllers/utils/checkUserAccess.js +19 -19
- package/server/routes/logger/controllers/utils/getRootDir.js +26 -26
- package/server/routes/logger/index.js +17 -17
- package/server/routes/properties/controllers/properties.add.js +55 -55
- package/server/routes/properties/controllers/properties.get.js +17 -17
- package/server/routes/properties/index.js +16 -16
- package/server/routes/table/controllers/data.js +156 -156
- package/server/routes/table/controllers/filter.js +66 -66
- package/server/routes/table/controllers/form.js +42 -42
- package/server/routes/table/controllers/search.js +74 -74
- package/server/routes/table/controllers/suggest.js +158 -158
- package/server/routes/table/index.js +29 -29
- package/server/routes/table/schema.js +64 -64
- package/server/routes/util/controllers/status.monitor.js +8 -8
- package/server/routes/util/index.js +11 -11
- package/utils.js +122 -122
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import applyHookSync from '../hook/funcs/applyHookSync.js';
|
|
2
|
-
|
|
3
|
-
function errorStatus(error) {
|
|
4
|
-
const hook = applyHookSync('errorStatus', error);
|
|
5
|
-
if (hook) return hook;
|
|
6
|
-
|
|
7
|
-
if (error.routine === 'exec_stmt_raise' && error.file === 'pl_exec.c') {
|
|
8
|
-
return 601;
|
|
9
|
-
}
|
|
10
|
-
if (error.routine === 'ExecConstraints') {
|
|
11
|
-
return 602;
|
|
12
|
-
}
|
|
13
|
-
if (error.type === 'DatabaseError') {
|
|
14
|
-
return 600;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return 500;
|
|
18
|
-
}
|
|
19
|
-
export default errorStatus;
|
|
1
|
+
import applyHookSync from '../hook/funcs/applyHookSync.js';
|
|
2
|
+
|
|
3
|
+
function errorStatus(error) {
|
|
4
|
+
const hook = applyHookSync('errorStatus', error);
|
|
5
|
+
if (hook) return hook;
|
|
6
|
+
|
|
7
|
+
if (error.routine === 'exec_stmt_raise' && error.file === 'pl_exec.c') {
|
|
8
|
+
return 601;
|
|
9
|
+
}
|
|
10
|
+
if (error.routine === 'ExecConstraints') {
|
|
11
|
+
return 602;
|
|
12
|
+
}
|
|
13
|
+
if (error.type === 'DatabaseError') {
|
|
14
|
+
return 600;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return 500;
|
|
18
|
+
}
|
|
19
|
+
export default errorStatus;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import errorMessage from './errorMessage.js';
|
|
2
|
-
|
|
3
|
-
async function plugin(fastify) {
|
|
4
|
-
fastify.setErrorHandler(async (error, request, reply) => {
|
|
5
|
-
// validation not error
|
|
6
|
-
if (error.validation) {
|
|
7
|
-
request.log.warn(request, { code: error?.code, status: 422, error: error.toString() });
|
|
8
|
-
return reply.status(422).send(error.toString());
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// logger
|
|
12
|
-
request.log.error(error, request);
|
|
13
|
-
console.error({ msg: error.message, where: error.where, stack: error.stack });
|
|
14
|
-
|
|
15
|
-
// errorMessage
|
|
16
|
-
const msg = errorMessage(error);
|
|
17
|
-
|
|
18
|
-
return reply.status(error.statusCode || 500).send(msg);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
export default plugin;
|
|
1
|
+
import errorMessage from './errorMessage.js';
|
|
2
|
+
|
|
3
|
+
async function plugin(fastify) {
|
|
4
|
+
fastify.setErrorHandler(async (error, request, reply) => {
|
|
5
|
+
// validation not error
|
|
6
|
+
if (error.validation) {
|
|
7
|
+
request.log.warn(request, { code: error?.code, status: 422, error: error.toString() });
|
|
8
|
+
return reply.status(422).send(error.toString());
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// logger
|
|
12
|
+
request.log.error(error, request);
|
|
13
|
+
console.error({ msg: error.message, where: error.where, stack: error.stack });
|
|
14
|
+
|
|
15
|
+
// errorMessage
|
|
16
|
+
const msg = errorMessage(error);
|
|
17
|
+
|
|
18
|
+
return reply.status(error.statusCode || 500).send(msg);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export default plugin;
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
const time = Date.now();
|
|
5
|
-
|
|
6
|
-
import getPG from '../../pg/funcs/getPG.js';
|
|
7
|
-
|
|
8
|
-
function getCallerDir() {
|
|
9
|
-
const originalFunc = Error.prepareStackTrace;
|
|
10
|
-
|
|
11
|
-
let callerfile;
|
|
12
|
-
try {
|
|
13
|
-
const err = new Error();
|
|
14
|
-
// let currentfile;
|
|
15
|
-
|
|
16
|
-
Error.prepareStackTrace = function (err, stack) { return stack; };
|
|
17
|
-
|
|
18
|
-
const currentfile = err.stack.shift().getFileName();
|
|
19
|
-
|
|
20
|
-
while (err.stack.length) {
|
|
21
|
-
callerfile = err.stack.shift().getFileName();
|
|
22
|
-
|
|
23
|
-
if (currentfile !== callerfile) break;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch (err) { }
|
|
27
|
-
|
|
28
|
-
Error.prepareStackTrace = originalFunc;
|
|
29
|
-
|
|
30
|
-
return path.dirname(callerfile);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function sequence(files, data, fn) {
|
|
34
|
-
return files.reduce((promise, filename) => promise.then(() => fn({
|
|
35
|
-
...data, filename,
|
|
36
|
-
})), Promise.resolve());
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function execSql({
|
|
40
|
-
pg, dir, filename,
|
|
41
|
-
}) {
|
|
42
|
-
const start = Date.now();
|
|
43
|
-
const filepath = path.join(dir, filename);
|
|
44
|
-
const sql = fs.readFileSync(filepath, 'utf-8');
|
|
45
|
-
try {
|
|
46
|
-
console.log(filename, 'start', Date.now() - start);
|
|
47
|
-
await pg.query(sql);
|
|
48
|
-
console.log(filename, 'finish', Date.now() - start);
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
console.log(filepath, 'error', err.toString(), Date.now() - start);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default async function execMigrations(opt) {
|
|
56
|
-
try {
|
|
57
|
-
const pg = opt?.pg || getPG({ name: 'client' });
|
|
58
|
-
const rootDir = getCallerDir();
|
|
59
|
-
const subdir = () => {
|
|
60
|
-
if (rootDir.endsWith('plugins')) {
|
|
61
|
-
return '../..';
|
|
62
|
-
} if (path.basename(rootDir) === 'server') {
|
|
63
|
-
return '..';
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const dir = path.join(rootDir.replace(/\\/g, '/').replace(/^file:\/\/\//, ''), subdir() || '', 'server/migrations');
|
|
67
|
-
|
|
68
|
-
console.log('migrations start', dir, Date.now() - time);
|
|
69
|
-
const exists = fs.existsSync(dir);
|
|
70
|
-
if (exists) {
|
|
71
|
-
// get directory sql file list
|
|
72
|
-
const content = fs.readdirSync(dir, { withFileTypes: true })
|
|
73
|
-
?.filter((el) => el.isFile() && path.extname(el.name) === '.sql')
|
|
74
|
-
?.map((el) => el.name) || [];
|
|
75
|
-
|
|
76
|
-
// execute sql files
|
|
77
|
-
if (content?.length) {
|
|
78
|
-
await sequence(content, { pg, dir }, execSql);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
console.log('migrations finish', dir, exists, Date.now() - time);
|
|
82
|
-
}
|
|
83
|
-
catch (err) {
|
|
84
|
-
console.error('migrations error', err.toString(), Date.now() - time);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
const time = Date.now();
|
|
5
|
+
|
|
6
|
+
import getPG from '../../pg/funcs/getPG.js';
|
|
7
|
+
|
|
8
|
+
function getCallerDir() {
|
|
9
|
+
const originalFunc = Error.prepareStackTrace;
|
|
10
|
+
|
|
11
|
+
let callerfile;
|
|
12
|
+
try {
|
|
13
|
+
const err = new Error();
|
|
14
|
+
// let currentfile;
|
|
15
|
+
|
|
16
|
+
Error.prepareStackTrace = function (err, stack) { return stack; };
|
|
17
|
+
|
|
18
|
+
const currentfile = err.stack.shift().getFileName();
|
|
19
|
+
|
|
20
|
+
while (err.stack.length) {
|
|
21
|
+
callerfile = err.stack.shift().getFileName();
|
|
22
|
+
|
|
23
|
+
if (currentfile !== callerfile) break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (err) { }
|
|
27
|
+
|
|
28
|
+
Error.prepareStackTrace = originalFunc;
|
|
29
|
+
|
|
30
|
+
return path.dirname(callerfile);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function sequence(files, data, fn) {
|
|
34
|
+
return files.reduce((promise, filename) => promise.then(() => fn({
|
|
35
|
+
...data, filename,
|
|
36
|
+
})), Promise.resolve());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function execSql({
|
|
40
|
+
pg, dir, filename,
|
|
41
|
+
}) {
|
|
42
|
+
const start = Date.now();
|
|
43
|
+
const filepath = path.join(dir, filename);
|
|
44
|
+
const sql = fs.readFileSync(filepath, 'utf-8');
|
|
45
|
+
try {
|
|
46
|
+
console.log(filename, 'start', Date.now() - start);
|
|
47
|
+
await pg.query(sql);
|
|
48
|
+
console.log(filename, 'finish', Date.now() - start);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
console.log(filepath, 'error', err.toString(), Date.now() - start);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default async function execMigrations(opt) {
|
|
56
|
+
try {
|
|
57
|
+
const pg = opt?.pg || getPG({ name: 'client' });
|
|
58
|
+
const rootDir = getCallerDir();
|
|
59
|
+
const subdir = () => {
|
|
60
|
+
if (rootDir.endsWith('plugins')) {
|
|
61
|
+
return '../..';
|
|
62
|
+
} if (path.basename(rootDir) === 'server') {
|
|
63
|
+
return '..';
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const dir = path.join(rootDir.replace(/\\/g, '/').replace(/^file:\/\/\//, ''), subdir() || '', 'server/migrations');
|
|
67
|
+
|
|
68
|
+
console.log('migrations start', dir, Date.now() - time);
|
|
69
|
+
const exists = fs.existsSync(dir);
|
|
70
|
+
if (exists) {
|
|
71
|
+
// get directory sql file list
|
|
72
|
+
const content = fs.readdirSync(dir, { withFileTypes: true })
|
|
73
|
+
?.filter((el) => el.isFile() && path.extname(el.name) === '.sql')
|
|
74
|
+
?.map((el) => el.name) || [];
|
|
75
|
+
|
|
76
|
+
// execute sql files
|
|
77
|
+
if (content?.length) {
|
|
78
|
+
await sequence(content, { pg, dir }, execSql);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
console.log('migrations finish', dir, exists, Date.now() - time);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
console.error('migrations error', err.toString(), Date.now() - time);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import execMigrations from './funcs/exec.migrations.js';
|
|
2
|
-
|
|
3
|
-
async function plugin(fastify) {
|
|
4
|
-
// fastify.decorate('execMigrations', execMigrations);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default plugin;
|
|
1
|
+
import execMigrations from './funcs/exec.migrations.js';
|
|
2
|
+
|
|
3
|
+
async function plugin(fastify) {
|
|
4
|
+
// fastify.decorate('execMigrations', execMigrations);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default plugin;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import pg from 'pg';
|
|
2
|
-
|
|
3
|
-
import config from '../../../config.js';
|
|
4
|
-
import init from './funcs/init.js';
|
|
5
|
-
|
|
6
|
-
const pgClients = {};
|
|
7
|
-
if (config.pg) {
|
|
8
|
-
const client = new pg.Pool({
|
|
9
|
-
host: config.pg?.host || '127.0.0.1',
|
|
10
|
-
port: config.pg?.port || 5432,
|
|
11
|
-
database: config.pg?.database || 'postgres',
|
|
12
|
-
user: config.pg?.user || 'postgres',
|
|
13
|
-
password: config.pg?.password || 'postgres',
|
|
14
|
-
});
|
|
15
|
-
client.init = async () => {
|
|
16
|
-
await init(client);
|
|
17
|
-
};
|
|
18
|
-
client.init();
|
|
19
|
-
pgClients.client = client;
|
|
20
|
-
}
|
|
21
|
-
export default pgClients;
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
|
|
3
|
+
import config from '../../../config.js';
|
|
4
|
+
import init from './funcs/init.js';
|
|
5
|
+
|
|
6
|
+
const pgClients = {};
|
|
7
|
+
if (config.pg) {
|
|
8
|
+
const client = new pg.Pool({
|
|
9
|
+
host: config.pg?.host || '127.0.0.1',
|
|
10
|
+
port: config.pg?.port || 5432,
|
|
11
|
+
database: config.pg?.database || 'postgres',
|
|
12
|
+
user: config.pg?.user || 'postgres',
|
|
13
|
+
password: config.pg?.password || 'postgres',
|
|
14
|
+
});
|
|
15
|
+
client.init = async () => {
|
|
16
|
+
await init(client);
|
|
17
|
+
};
|
|
18
|
+
client.init();
|
|
19
|
+
pgClients.client = client;
|
|
20
|
+
}
|
|
21
|
+
export default pgClients;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import checkPolicy from './funcs/checkPolicy.js';
|
|
2
|
-
|
|
3
|
-
async function plugin(fastify) {
|
|
4
|
-
fastify.addHook('preParsing', async (request, reply) => {
|
|
5
|
-
const hookData = checkPolicy(request);
|
|
6
|
-
if (hookData?.status && hookData?.message) {
|
|
7
|
-
return reply.status(hookData?.status).send(hookData.message);
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default plugin;
|
|
1
|
+
import checkPolicy from './funcs/checkPolicy.js';
|
|
2
|
+
|
|
3
|
+
async function plugin(fastify) {
|
|
4
|
+
fastify.addHook('preParsing', async (request, reply) => {
|
|
5
|
+
const hookData = checkPolicy(request);
|
|
6
|
+
if (hookData?.status && hookData?.message) {
|
|
7
|
+
return reply.status(hookData?.status).send(hookData.message);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default plugin;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
const sqlInjection = [
|
|
2
|
-
'()',
|
|
3
|
-
'^',
|
|
4
|
-
'*',
|
|
5
|
-
'like ',
|
|
6
|
-
'@variable',
|
|
7
|
-
'@@variable',
|
|
8
|
-
'group by ',
|
|
9
|
-
'union ',
|
|
10
|
-
'select ',
|
|
11
|
-
'having ',
|
|
12
|
-
'as injectx',
|
|
13
|
-
'where ',
|
|
14
|
-
'rlike ',
|
|
15
|
-
'if(',
|
|
16
|
-
'sleep(',
|
|
17
|
-
'waitfor delay',
|
|
18
|
-
'benchmark(',
|
|
19
|
-
'pg_sleep(',
|
|
20
|
-
"'\\\"",
|
|
21
|
-
'randomblob(',
|
|
22
|
-
'order by ',
|
|
23
|
-
'union all ',
|
|
24
|
-
'+or',
|
|
25
|
-
'or ',
|
|
26
|
-
'and ',
|
|
27
|
-
"'' ",
|
|
28
|
-
'""" ',
|
|
29
|
-
'<script',
|
|
30
|
-
'javascript:',
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
export default sqlInjection;
|
|
1
|
+
const sqlInjection = [
|
|
2
|
+
'()',
|
|
3
|
+
'^',
|
|
4
|
+
'*',
|
|
5
|
+
'like ',
|
|
6
|
+
'@variable',
|
|
7
|
+
'@@variable',
|
|
8
|
+
'group by ',
|
|
9
|
+
'union ',
|
|
10
|
+
'select ',
|
|
11
|
+
'having ',
|
|
12
|
+
'as injectx',
|
|
13
|
+
'where ',
|
|
14
|
+
'rlike ',
|
|
15
|
+
'if(',
|
|
16
|
+
'sleep(',
|
|
17
|
+
'waitfor delay',
|
|
18
|
+
'benchmark(',
|
|
19
|
+
'pg_sleep(',
|
|
20
|
+
"'\\\"",
|
|
21
|
+
'randomblob(',
|
|
22
|
+
'order by ',
|
|
23
|
+
'union all ',
|
|
24
|
+
'+or',
|
|
25
|
+
'or ',
|
|
26
|
+
'and ',
|
|
27
|
+
"'' ",
|
|
28
|
+
'""" ',
|
|
29
|
+
'<script',
|
|
30
|
+
'javascript:',
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export default sqlInjection;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import redisClients from './funcs/redisClients.js';
|
|
2
|
-
import getRedis from './funcs/getRedis.js';
|
|
3
|
-
|
|
4
|
-
if (!redisClients[0]) {
|
|
5
|
-
getRedis({ db: 0 });
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default redisClients[0];
|
|
1
|
+
import redisClients from './funcs/redisClients.js';
|
|
2
|
+
import getRedis from './funcs/getRedis.js';
|
|
3
|
+
|
|
4
|
+
if (!redisClients[0]) {
|
|
5
|
+
getRedis({ db: 0 });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default redisClients[0];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const redisClients = {};
|
|
2
|
-
|
|
3
|
-
export default redisClients;
|
|
1
|
+
const redisClients = {};
|
|
2
|
+
|
|
3
|
+
export default redisClients;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// import redis from './client.js';
|
|
2
|
-
import redisClients from './funcs/redisClients.js';
|
|
3
|
-
|
|
4
|
-
function close(fastify) {
|
|
5
|
-
// redis.quit();
|
|
6
|
-
Object.keys(redisClients).forEach((key) => redisClients[key].quit());
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
async function plugin(fastify) {
|
|
10
|
-
// const client = getRedis({ db: 0 });
|
|
11
|
-
// client.getJSON = client.get;
|
|
12
|
-
// fastify.decorate('rclient', client);
|
|
13
|
-
// fastify.decorate('getRedis', getRedis);
|
|
14
|
-
fastify.addHook('onClose', close);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default plugin;
|
|
1
|
+
// import redis from './client.js';
|
|
2
|
+
import redisClients from './funcs/redisClients.js';
|
|
3
|
+
|
|
4
|
+
function close(fastify) {
|
|
5
|
+
// redis.quit();
|
|
6
|
+
Object.keys(redisClients).forEach((key) => redisClients[key].quit());
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async function plugin(fastify) {
|
|
10
|
+
// const client = getRedis({ db: 0 });
|
|
11
|
+
// client.getJSON = client.get;
|
|
12
|
+
// fastify.decorate('rclient', client);
|
|
13
|
+
// fastify.decorate('getRedis', getRedis);
|
|
14
|
+
fastify.addHook('onClose', close);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default plugin;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import userTemplateDir from './userTemplateDir.js';
|
|
2
|
-
|
|
3
|
-
export default function addTemplateDir(dir) {
|
|
4
|
-
if (dir) {
|
|
5
|
-
userTemplateDir.push(dir);
|
|
6
|
-
}
|
|
7
|
-
return userTemplateDir;
|
|
8
|
-
}
|
|
1
|
+
import userTemplateDir from './userTemplateDir.js';
|
|
2
|
+
|
|
3
|
+
export default function addTemplateDir(dir) {
|
|
4
|
+
if (dir) {
|
|
5
|
+
userTemplateDir.push(dir);
|
|
6
|
+
}
|
|
7
|
+
return userTemplateDir;
|
|
8
|
+
}
|