@opengis/fastify-table 1.2.18 → 1.2.20

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.
Files changed (52) hide show
  1. package/README.md +86 -86
  2. package/index.js +6 -3
  3. package/package.json +1 -1
  4. package/server/migrations/cls.sql +39 -39
  5. package/server/plugins/cron/funcs/addCron.js +130 -130
  6. package/server/plugins/cron/index.js +6 -6
  7. package/server/plugins/crud/funcs/getOpt.js +13 -13
  8. package/server/plugins/crud/funcs/setOpt.js +21 -21
  9. package/server/plugins/crud/funcs/setToken.js +44 -44
  10. package/server/plugins/crud/funcs/utils/getFolder.js +10 -10
  11. package/server/plugins/crud/index.js +23 -23
  12. package/server/plugins/hook/index.js +8 -8
  13. package/server/plugins/logger/errorStatus.js +19 -19
  14. package/server/plugins/logger/getLogger.js +13 -3
  15. package/server/plugins/logger/index.js +21 -21
  16. package/server/plugins/metric/index.js +8 -0
  17. package/server/plugins/metric/loggerSystem.js +129 -0
  18. package/server/plugins/metric/systemMetricsFifthly.js +23 -0
  19. package/server/plugins/migration/index.js +7 -7
  20. package/server/plugins/pg/pgClients.js +21 -21
  21. package/server/plugins/policy/sqlInjection.js +33 -33
  22. package/server/plugins/redis/client.js +8 -8
  23. package/server/plugins/redis/funcs/redisClients.js +3 -3
  24. package/server/plugins/redis/index.js +17 -17
  25. package/server/plugins/table/funcs/addTemplateDir.js +8 -8
  26. package/server/plugins/table/funcs/getFilterSQL/index.js +96 -96
  27. package/server/plugins/table/funcs/getFilterSQL/util/getCustomQuery.js +13 -13
  28. package/server/plugins/table/funcs/getFilterSQL/util/getOptimizedQuery.js +12 -12
  29. package/server/plugins/table/funcs/getFilterSQL/util/getTableSql.js +34 -34
  30. package/server/plugins/table/funcs/getTemplates.js +19 -19
  31. package/server/plugins/table/funcs/gisIRColumn.js +82 -82
  32. package/server/plugins/table/funcs/loadTemplate.js +1 -1
  33. package/server/plugins/table/funcs/loadTemplatePath.js +1 -1
  34. package/server/plugins/table/funcs/userTemplateDir.js +1 -1
  35. package/server/plugins/table/index.js +13 -13
  36. package/server/plugins/util/index.js +7 -7
  37. package/server/routes/cron/index.js +14 -14
  38. package/server/routes/crud/controllers/table.js +91 -91
  39. package/server/routes/logger/controllers/logger.file.js +92 -92
  40. package/server/routes/logger/controllers/utils/checkUserAccess.js +19 -19
  41. package/server/routes/logger/controllers/utils/getRootDir.js +26 -26
  42. package/server/routes/logger/index.js +17 -17
  43. package/server/routes/properties/controllers/properties.add.js +55 -55
  44. package/server/routes/properties/controllers/properties.get.js +17 -17
  45. package/server/routes/properties/index.js +16 -16
  46. package/server/routes/table/controllers/data.js +32 -30
  47. package/server/routes/table/controllers/form.js +42 -42
  48. package/server/routes/table/controllers/search.js +74 -74
  49. package/server/routes/table/index.js +29 -29
  50. package/server/routes/table/schema.js +64 -64
  51. package/server/routes/util/controllers/status.monitor.js +8 -8
  52. package/server/routes/util/index.js +11 -11
@@ -1,44 +1,44 @@
1
- import { createHash, randomUUID } from 'crypto';
2
-
3
- import config from '../../../../config.js';
4
-
5
- import getRedis from '../../redis/funcs/getRedis.js';
6
-
7
- const rclient = getRedis({ db: 0 });
8
-
9
- // import { config, getRedis } from '../../../../utils.js';
10
-
11
- const generateCodes = (ids, userToken) => {
12
- const token = userToken || randomUUID();
13
- const notNullIds = ids.filter((el) => el);
14
- const obj = {};
15
- const codes = notNullIds.reduce((acc, id) => {
16
- const newToken = createHash('sha1').update(token + id).digest('base64url').replace(/-/g, '');
17
- acc[newToken] = id; obj[id] = newToken;
18
- return acc;
19
- }, {});
20
- return { codes, obj };
21
- };
22
-
23
- function setToken({
24
- ids: idsOrigin, uid, array,
25
- }) {
26
- // const rclient5 = getRedis({ db: 0, funcs });
27
-
28
- if (!uid) return { user: 'empty' };
29
- if (!Object.keys(idsOrigin).length) return { ids: 'empty' };
30
-
31
- const ids = idsOrigin.map((el) => (typeof el === 'object' ? JSON.stringify(el) : el));
32
-
33
- // TODO generate salt
34
- const { codes, obj } = generateCodes(ids, uid);
35
-
36
- if (!Object.keys(codes).length) return { ids: 'empty' };
37
-
38
- rclient.hmset(`${config.pg.database}:token:edit:${uid}`, codes);
39
- // console.log(`${config.pg.database}:token:edit:${uid}`, idsOrigin, Object.values(obj));
40
- // TODO дополнительно писать в hset token -> uid
41
- return array ? Object.values(obj) : obj;
42
- }
43
-
44
- export default setToken;
1
+ import { createHash, randomUUID } from 'crypto';
2
+
3
+ import config from '../../../../config.js';
4
+
5
+ import getRedis from '../../redis/funcs/getRedis.js';
6
+
7
+ const rclient = getRedis({ db: 0 });
8
+
9
+ // import { config, getRedis } from '../../../../utils.js';
10
+
11
+ const generateCodes = (ids, userToken) => {
12
+ const token = userToken || randomUUID();
13
+ const notNullIds = ids.filter((el) => el);
14
+ const obj = {};
15
+ const codes = notNullIds.reduce((acc, id) => {
16
+ const newToken = createHash('sha1').update(token + id).digest('base64url').replace(/-/g, '');
17
+ acc[newToken] = id; obj[id] = newToken;
18
+ return acc;
19
+ }, {});
20
+ return { codes, obj };
21
+ };
22
+
23
+ function setToken({
24
+ ids: idsOrigin, uid, array,
25
+ }) {
26
+ // const rclient5 = getRedis({ db: 0, funcs });
27
+
28
+ if (!uid) return { user: 'empty' };
29
+ if (!Object.keys(idsOrigin).length) return { ids: 'empty' };
30
+
31
+ const ids = idsOrigin.map((el) => (typeof el === 'object' ? JSON.stringify(el) : el));
32
+
33
+ // TODO generate salt
34
+ const { codes, obj } = generateCodes(ids, uid);
35
+
36
+ if (!Object.keys(codes).length) return { ids: 'empty' };
37
+
38
+ rclient.hmset(`${config.pg.database}:token:edit:${uid}`, codes);
39
+ // console.log(`${config.pg.database}:token:edit:${uid}`, idsOrigin, Object.values(obj));
40
+ // TODO дополнительно писать в hset token -> uid
41
+ return array ? Object.values(obj) : obj;
42
+ }
43
+
44
+ export default setToken;
@@ -1,10 +1,10 @@
1
- import path from 'node:path';
2
-
3
- import config from '../../../../../config.js';
4
-
5
- export default function getFolder(req, type = 'server') {
6
- if (!['server', 'local'].includes(type)) throw new Error('params type is invalid');
7
- const types = { local: req.root || config.root, server: req.mapServerRoot || config.mapServerRoot };
8
- const filepath = path.posix.join(types[type] || `/data/local/${req.pg?.options?.database || ''}`, req.folder || config.folder || '');
9
- return filepath;
10
- }
1
+ import path from 'node:path';
2
+
3
+ import config from '../../../../../config.js';
4
+
5
+ export default function getFolder(req, type = 'server') {
6
+ if (!['server', 'local'].includes(type)) throw new Error('params type is invalid');
7
+ const types = { local: req.root || config.root, server: req.mapServerRoot || config.mapServerRoot };
8
+ const filepath = path.posix.join(types[type] || `/data/local/${req.pg?.options?.database || ''}`, req.folder || config.folder || '');
9
+ return filepath;
10
+ }
@@ -1,23 +1,23 @@
1
- // import getOpt from './funcs/getOpt.js';
2
- // import setOpt from './funcs/setOpt.js';
3
-
4
- // import isFileExists from './funcs/isFileExists.js';
5
-
6
- // import dataUpdate from './funcs/dataUpdate.js';
7
- // import dataInsert from './funcs/dataInsert.js';
8
-
9
- // import getAccessFunc from './funcs/getAccess.js';
10
-
11
- async function plugin(fastify) {
12
- // fastify.decorate('setOpt', setOpt);
13
- // fastify.decorate('getOpt', getOpt);
14
-
15
- // fastify.decorate('dataUpdate', dataUpdate);
16
- // fastify.decorate('dataInsert', dataInsert);
17
-
18
- // fastify.decorate('getAccess', getAccessFunc);
19
-
20
- // fastify.decorate('isFileExists', isFileExists);
21
- }
22
-
23
- export default plugin;
1
+ // import getOpt from './funcs/getOpt.js';
2
+ // import setOpt from './funcs/setOpt.js';
3
+
4
+ // import isFileExists from './funcs/isFileExists.js';
5
+
6
+ // import dataUpdate from './funcs/dataUpdate.js';
7
+ // import dataInsert from './funcs/dataInsert.js';
8
+
9
+ // import getAccessFunc from './funcs/getAccess.js';
10
+
11
+ async function plugin(fastify) {
12
+ // fastify.decorate('setOpt', setOpt);
13
+ // fastify.decorate('getOpt', getOpt);
14
+
15
+ // fastify.decorate('dataUpdate', dataUpdate);
16
+ // fastify.decorate('dataInsert', dataInsert);
17
+
18
+ // fastify.decorate('getAccess', getAccessFunc);
19
+
20
+ // fastify.decorate('isFileExists', isFileExists);
21
+ }
22
+
23
+ export default plugin;
@@ -1,8 +1,8 @@
1
- import addHook from './funcs/addHook.js';
2
- import applyHook from './funcs/applyHook.js';
3
-
4
- async function plugin(fastify) {
5
- // fastify.decorate('addHook', addHook);
6
- // fastify.decorate('applyHook', applyHook);
7
- }
8
- export default plugin;
1
+ import addHook from './funcs/addHook.js';
2
+ import applyHook from './funcs/applyHook.js';
3
+
4
+ async function plugin(fastify) {
5
+ // fastify.decorate('addHook', addHook);
6
+ // fastify.decorate('applyHook', applyHook);
7
+ }
8
+ export default plugin;
@@ -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,14 +1,18 @@
1
1
  import pino from 'pino';
2
2
  // import path from 'node:path';
3
3
 
4
- import config from '../../../config.js';
5
-
6
- if (!config.log) config.log = {};
4
+ import { config, getRedis } from '../../../utils.js';
7
5
 
8
6
  // utils
9
7
  import getHooks from './getHooks.js';
10
8
  import serializers from './serializers.js';
11
9
 
10
+ const isServer = process.argv[2];
11
+
12
+ const rclient2 = getRedis();
13
+
14
+ if (!config.log) config.log = {};
15
+
12
16
  const level = config.log?.level || process.env.PINO_LOG_LEVEL || 'info';
13
17
  console.log(`log level: ${level}`);
14
18
  const options = {
@@ -32,4 +36,10 @@ const logger = pino(options);
32
36
  logger.file = function userFile(logfolder, msg, req) {
33
37
  logger.info({ logfolder, ...(typeof msg === 'string' ? { msg } : msg) }, req);
34
38
  };
39
+ logger.metrics = function metrics(key, val, dbName) {
40
+ const dbname = dbName || config.pg?.database;
41
+ if (!dbname && !isServer) return;
42
+ rclient2.hincrby(`${dbname}:system_metrics`, key, val || 1);
43
+ };
44
+
35
45
  export default logger;
@@ -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;
@@ -0,0 +1,8 @@
1
+ import addCron from '../cron/funcs/addCron.js';
2
+ import systemMetricsFifthly from './systemMetricsFifthly.js';
3
+
4
+ async function plugin(fastify) {
5
+ addCron(systemMetricsFifthly, 60 * 15);
6
+ }
7
+
8
+ export default plugin;
@@ -0,0 +1,129 @@
1
+ import os from 'os';
2
+ import process from 'process';
3
+ import util from 'node:util';
4
+ import { exec } from 'node:child_process';
5
+
6
+ import { config, getFolder, pgClients, getRedis } from '../../../utils.js';
7
+
8
+ const execAsync = util.promisify(exec);
9
+ const platform = os.platform();
10
+ const processFolder = os.homedir();
11
+ const formatMemoryUsage = (data) => `${(data / 1024 / 1024).toFixed(2)} MB`;
12
+
13
+ const rclient = getRedis();
14
+ const rclient2 = getRedis({ db: 2 });
15
+ // const rclient10 = getRedis({ db: 10 });
16
+ const filesFolder = getFolder(config);
17
+
18
+ const redisKey = 'logger-process-online';
19
+ const sqlQuery = `select datname as dbname, application_name as app, client_addr as client_ip,
20
+ (now()-backend_start)::text as msec, state, query from pg_stat_activity where datname=$1`;
21
+
22
+ export default async function loggerSystem(req) {
23
+ const { pg = pgClients.client } = req;
24
+ const dbName = pg.options?.database;
25
+
26
+ const dbsize = await rclient.get(`${dbName}:content:dbsize:${redisKey}`);
27
+
28
+ const dbVerion = await pg.query('select version();').then(el => el.rows?.[0]?.version);
29
+
30
+ const dbSize = dbsize
31
+ || (await pg.query(`select pg_size_pretty(pg_database_size('${dbName}'));`).then(el => el.rows?.[0]?.pg_size_pretty));
32
+
33
+ const { rows: query = [] } = await pg.query(sqlQuery, [dbName]);
34
+
35
+ const { stdout: topProcess } = platform === 'win32'
36
+ ? { stdout: 'Cant show top on this system type' }
37
+ : await execAsync('top -b -n 1');
38
+
39
+ const osInfo = `${os.version()} ${os.machine?.() || ''}`;
40
+ const cpuInfo = os.cpus();
41
+
42
+ const totalCpu = (Object.values(cpuInfo[0].times).reduce((acc, tv) => acc + tv, 0)) * cpuInfo.length;
43
+ const totalMemory = os.totalmem();
44
+
45
+ const memory = process.memoryUsage();
46
+ const resource = process.resourceUsage();
47
+
48
+ const currentCpuUsage = (((process.cpuUsage().user + process.cpuUsage().system) * 1000) / totalCpu) * 100;
49
+ const redisInfo = await rclient.info();
50
+
51
+ const lines = redisInfo.split('\r\n').filter((el) => el && el.split);
52
+ const redis = {};
53
+
54
+ for (let i = 0; i < lines.length; i += 1) {
55
+ const [key, val] = lines[i].split(':');
56
+ if (val) {
57
+ redis[key] = val;
58
+ }
59
+ }
60
+
61
+ await rclient.set(`${dbName}:content:dbsize:${redisKey}`, dbSize, 'EX', 30 * 60);
62
+
63
+ const latency = await rclient.latency('latest');
64
+
65
+ const uptime = await pg.query(`select extract('epoch' from current_timestamp - pg_postmaster_start_time())::int as uptime`)
66
+ .then(el => el.rows?.[0]?.uptime);
67
+
68
+ const metric5 = await rclient2.hgetall(`${dbName}:system_metrics`);
69
+
70
+ Object.keys(metric5 || {}).filter((el) => el.startsWith('time')).forEach((m) => {
71
+ metric5[m] /= 1000.0;
72
+ });
73
+
74
+ const metricSort = metric5 ? JSON.parse(JSON.stringify(metric5, Object.keys(metric5).sort())) : undefined;
75
+ const userOnline = await rclient2.scan(['0', 'match', `${dbName}:user:*`, 'count', '10000']);
76
+ // const userOnline = await rclient10.scan(['0', 'match', 'sess:*', 'count', '10000']);
77
+
78
+ return {
79
+ process: {
80
+ root: process.cwd(),
81
+ processFolder,
82
+ saveDirectory: filesFolder,
83
+ dbhost: pg.options?.host,
84
+ dbport: pg.options?.port,
85
+ dbname: dbName,
86
+ },
87
+
88
+ uptime: {
89
+ node: Math.round(process.uptime()),
90
+ system: os.uptime(),
91
+ pg: uptime,
92
+ redis: redis.uptime_in_seconds - 0,
93
+ },
94
+ metric: {
95
+ cpu: `${Math.round(currentCpuUsage)} %`,
96
+ memory: `${Math.round(((memory.rss / totalMemory) * 100) * 100) / 100} %`,
97
+ 'user.online': userOnline?.[1]?.length,
98
+ 'node.total': formatMemoryUsage(memory.heapTotal),
99
+ 'node.used': formatMemoryUsage(memory.heapUsed),
100
+ 'node.rss': formatMemoryUsage(memory.rss),
101
+ 'node.cpu.time': resource.systemCPUTime,
102
+ 'node.cpu.load': os.loadavg()[0],
103
+ 'redis.ram': redis.used_memory_human,
104
+ 'redis.latency': latency?.join(','),
105
+ 'redis.ram.peak': redis.used_memory_peak_human,
106
+ 'redis.clients': redis.connected_clients,
107
+ 'redis.db0': redis.db0?.split(',')?.[0]?.substring(5),
108
+ 'redis.db1': redis.db1?.split(',')?.[0]?.substring(5),
109
+ 'redis.db2': redis.db2?.split(',')?.[0]?.substring(5),
110
+ 'redis.db10': redis.db10?.split(',')?.[0]?.substring(5),
111
+ 'pg.connection': query?.length,
112
+ dbsize: dbSize,
113
+ filesize: 0,
114
+ },
115
+ metricSort,
116
+ system: {
117
+ os: osInfo,
118
+ release: os.release(),
119
+ core: cpuInfo.length,
120
+ cpu: cpuInfo[0].model,
121
+ ram: formatMemoryUsage(totalMemory),
122
+ db: dbVerion,
123
+ redis: rclient.server_info?.redis_version,
124
+ node: process.version,
125
+ },
126
+ top: topProcess,
127
+ query,
128
+ };
129
+ };
@@ -0,0 +1,23 @@
1
+ import pgClients from '../pg/pgClients.js';
2
+ import logger from '../logger/getLogger.js';
3
+ import getRedis from '../redis/funcs/getRedis.js';
4
+
5
+ import loggerSystem from './loggerSystem.js';
6
+
7
+ const rclient2 = getRedis({ db: 2 });
8
+
9
+ export default async function systemMetricsFifthly({ pg = pgClients.client }) {
10
+ const system = await loggerSystem({ pg });
11
+ const dbName = pg.options?.database;
12
+
13
+ await rclient2.del(`${dbName}:system_metrics`);
14
+
15
+ logger.file('metric', {
16
+ dbname: dbName,
17
+ ...system.metric,
18
+ uptime: system.uptime,
19
+ ...system.metricSort,
20
+ });
21
+
22
+ return { message: 'Saved Fifthly' };
23
+ }
@@ -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,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
+ }