@opengis/fastify-table 1.0.26 → 1.0.27
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/.eslintrc.cjs +42 -42
- package/Changelog.md +81 -81
- package/README.md +26 -26
- package/config.js +11 -11
- package/crud/controllers/deleteCrud.js +14 -14
- package/crud/controllers/insert.js +29 -29
- package/crud/controllers/update.js +31 -31
- package/crud/controllers/utils/checkXSS.js +45 -45
- package/crud/controllers/utils/xssInjection.js +72 -72
- package/crud/funcs/dataDelete.js +15 -15
- package/crud/funcs/dataInsert.js +24 -24
- package/crud/funcs/dataUpdate.js +24 -20
- package/crud/funcs/getOpt.js +10 -10
- package/crud/funcs/getToken.js +27 -27
- package/crud/funcs/isFileExists.js +13 -13
- package/crud/funcs/setOpt.js +16 -16
- package/crud/funcs/setToken.js +53 -53
- package/crud/index.js +29 -29
- package/dblist/controllers/createItem.js +17 -17
- package/dblist/controllers/deleteItem.js +12 -12
- package/dblist/controllers/readItems.js +8 -8
- package/dblist/controllers/updateItem.js +22 -22
- package/dblist/controllers/utils/checkItem.js +9 -9
- package/dblist/index.js +40 -40
- package/helper.js +28 -28
- package/index.js +41 -41
- package/notification/controllers/userNotifications.js +19 -19
- package/notification/funcs/addNotification.js +8 -8
- package/notification/index.js +19 -19
- package/package.json +22 -22
- package/pg/funcs/getPG.js +29 -29
- package/pg/pgClients.js +20 -20
- package/policy/funcs/checkPolicy.js +74 -74
- package/policy/funcs/sqlInjection.js +33 -33
- package/policy/index.js +14 -14
- package/redis/client.js +8 -8
- package/redis/funcs/getRedis.js +23 -23
- package/redis/funcs/redisClients.js +2 -2
- package/redis/index.js +19 -19
- package/server/migrations/crm.sql +57 -57
- package/server/migrations/log.sql +41 -41
- package/server/migrations/notifications.sql +14 -14
- package/server/templates/form/test.dataset.form.json +411 -411
- package/server/templates/select/test.storage.data.json +2 -2
- package/server/templates/table/test.dataset.table.json +24 -24
- package/server.js +14 -14
- package/table/controllers/data.js +57 -57
- package/table/controllers/filter.js +32 -32
- package/table/controllers/form.js +10 -10
- package/table/controllers/search.js +41 -41
- package/table/controllers/suggest.js +60 -60
- package/table/controllers/utils/getSelect.js +20 -20
- package/table/controllers/utils/getSelectMeta.js +66 -66
- package/table/controllers/utils/getTemplate.js +28 -28
- package/table/funcs/getFilterSQL/index.js +75 -75
- package/table/funcs/getFilterSQL/util/formatValue.js +142 -142
- package/table/funcs/getFilterSQL/util/getCustomQuery.js +13 -13
- package/table/funcs/getFilterSQL/util/getFilterQuery.js +73 -73
- package/table/funcs/getFilterSQL/util/getOptimizedQuery.js +12 -12
- package/table/funcs/getFilterSQL/util/getTableSql.js +34 -34
- package/table/funcs/metaFormat/getSelectVal.js +20 -20
- package/table/funcs/metaFormat/index.js +26 -26
- package/table/index.js +42 -42
- package/test/api/crud.test.js +56 -56
- package/test/api/crud.xss.test.js +71 -71
- package/test/api/dblist.test.js +47 -47
- package/test/api/notification.test.js +37 -37
- package/test/api/table.test.js +57 -57
- package/test/api/widget.test.js +39 -39
- package/test/config.example +18 -18
- package/test/funcs/crud.test.js +76 -76
- package/test/funcs/notification.test.js +31 -31
- package/test/funcs/pg.test.js +34 -34
- package/test/funcs/redis.test.js +19 -19
- package/test/templates/cls/test.json +9 -9
- package/test/templates/form/cp_building.form.json +32 -32
- package/test/templates/select/account_id.json +3 -3
- package/test/templates/select/storage.data.json +2 -2
- package/test/templates/table/gis.dataset.table.json +20 -20
- package/test/widget.test.js +39 -39
- package/widget/controllers/utils/historyFormat.js +76 -76
- package/widget/controllers/utils/obj2db.js +13 -13
- package/widget/controllers/widget.del.js +40 -40
- package/widget/controllers/widget.get.js +74 -74
- package/widget/controllers/widget.set.js +45 -45
- package/widget/index.js +29 -29
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import build from '../../helper.js';
|
|
5
|
-
|
|
6
|
-
import setToken from '../../crud/funcs/setToken.js';
|
|
7
|
-
import config from '../config.js';
|
|
8
|
-
|
|
9
|
-
test('api crud xss', async (t) => {
|
|
10
|
-
const app = await build(t);
|
|
11
|
-
const session = { passport: { user: { uid: '1' } } };
|
|
12
|
-
app.addHook('onRequest', async (req) => {
|
|
13
|
-
req.session = session;
|
|
14
|
-
});
|
|
15
|
-
// app.decorateRequest('session', session);
|
|
16
|
-
|
|
17
|
-
const prefix = config.prefix || '/api';
|
|
18
|
-
|
|
19
|
-
let addTokens;
|
|
20
|
-
let editTokens;
|
|
21
|
-
|
|
22
|
-
// before
|
|
23
|
-
t.test('setToken', async () => {
|
|
24
|
-
addTokens = setToken({
|
|
25
|
-
ids: [JSON.stringify({ add: 'gis.dataset', form: 'test.dataset.form' })],
|
|
26
|
-
mode: 'a',
|
|
27
|
-
uid: 1,
|
|
28
|
-
array: 1,
|
|
29
|
-
});
|
|
30
|
-
editTokens = setToken({
|
|
31
|
-
ids: [JSON.stringify({ id: '5400000', table: 'gis.dataset', form: 'test.dataset.form' })],
|
|
32
|
-
mode: 'w',
|
|
33
|
-
uid: 1,
|
|
34
|
-
array: 1,
|
|
35
|
-
});
|
|
36
|
-
assert.ok(addTokens.length === 1 && editTokens.length === 1, 'invalid token');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
await t.test('POST /insert', async () => {
|
|
40
|
-
const res = await app.inject({
|
|
41
|
-
method: 'POST',
|
|
42
|
-
url: `${prefix}/table/${addTokens[0]}`,
|
|
43
|
-
body: { dataset_name: '<a onClick="alert("XSS Injection")">xss injection</a>', dataset_id: '5400000' },
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const rep = JSON.parse(res?.body);
|
|
47
|
-
|
|
48
|
-
assert.ok(rep.status, 409);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
await t.test('PUT /update', async () => {
|
|
52
|
-
const res = await app.inject({
|
|
53
|
-
method: 'PUT',
|
|
54
|
-
url: `${prefix}/table/${editTokens[0]}/${editTokens[0]}`,
|
|
55
|
-
body: { editor_id: '11', dataset_name: '<a onClick="alert("XSS Injection")">xss injection</a>' },
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const rep = JSON.parse(res?.body);
|
|
59
|
-
|
|
60
|
-
assert.equal(rep.status, 409);
|
|
61
|
-
});
|
|
62
|
-
await t.test('DELETE /delete', async () => {
|
|
63
|
-
const res = await app.inject({
|
|
64
|
-
method: 'DELETE',
|
|
65
|
-
url: `${prefix}/table/gis.dataset/5400000`,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const rep = JSON.parse(res?.body);
|
|
69
|
-
assert.ok(rep);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import build from '../../helper.js';
|
|
5
|
+
|
|
6
|
+
import setToken from '../../crud/funcs/setToken.js';
|
|
7
|
+
import config from '../config.js';
|
|
8
|
+
|
|
9
|
+
test('api crud xss', async (t) => {
|
|
10
|
+
const app = await build(t);
|
|
11
|
+
const session = { passport: { user: { uid: '1' } } };
|
|
12
|
+
app.addHook('onRequest', async (req) => {
|
|
13
|
+
req.session = session;
|
|
14
|
+
});
|
|
15
|
+
// app.decorateRequest('session', session);
|
|
16
|
+
|
|
17
|
+
const prefix = config.prefix || '/api';
|
|
18
|
+
|
|
19
|
+
let addTokens;
|
|
20
|
+
let editTokens;
|
|
21
|
+
|
|
22
|
+
// before
|
|
23
|
+
t.test('setToken', async () => {
|
|
24
|
+
addTokens = setToken({
|
|
25
|
+
ids: [JSON.stringify({ add: 'gis.dataset', form: 'test.dataset.form' })],
|
|
26
|
+
mode: 'a',
|
|
27
|
+
uid: 1,
|
|
28
|
+
array: 1,
|
|
29
|
+
});
|
|
30
|
+
editTokens = setToken({
|
|
31
|
+
ids: [JSON.stringify({ id: '5400000', table: 'gis.dataset', form: 'test.dataset.form' })],
|
|
32
|
+
mode: 'w',
|
|
33
|
+
uid: 1,
|
|
34
|
+
array: 1,
|
|
35
|
+
});
|
|
36
|
+
assert.ok(addTokens.length === 1 && editTokens.length === 1, 'invalid token');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await t.test('POST /insert', async () => {
|
|
40
|
+
const res = await app.inject({
|
|
41
|
+
method: 'POST',
|
|
42
|
+
url: `${prefix}/table/${addTokens[0]}`,
|
|
43
|
+
body: { dataset_name: '<a onClick="alert("XSS Injection")">xss injection</a>', dataset_id: '5400000' },
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const rep = JSON.parse(res?.body);
|
|
47
|
+
|
|
48
|
+
assert.ok(rep.status, 409);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
await t.test('PUT /update', async () => {
|
|
52
|
+
const res = await app.inject({
|
|
53
|
+
method: 'PUT',
|
|
54
|
+
url: `${prefix}/table/${editTokens[0]}/${editTokens[0]}`,
|
|
55
|
+
body: { editor_id: '11', dataset_name: '<a onClick="alert("XSS Injection")">xss injection</a>' },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const rep = JSON.parse(res?.body);
|
|
59
|
+
|
|
60
|
+
assert.equal(rep.status, 409);
|
|
61
|
+
});
|
|
62
|
+
await t.test('DELETE /delete', async () => {
|
|
63
|
+
const res = await app.inject({
|
|
64
|
+
method: 'DELETE',
|
|
65
|
+
url: `${prefix}/table/gis.dataset/5400000`,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const rep = JSON.parse(res?.body);
|
|
69
|
+
assert.ok(rep);
|
|
70
|
+
});
|
|
71
|
+
});
|
package/test/api/dblist.test.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import build from '../../helper.js';
|
|
5
|
-
import config from '../config.js';
|
|
6
|
-
|
|
7
|
-
const prefix = config.prefix || '/api';
|
|
8
|
-
|
|
9
|
-
test('api dblist', async (t) => {
|
|
10
|
-
const app = await build(t);
|
|
11
|
-
await t.test('GET /list', async () => {
|
|
12
|
-
const res = await app.inject({
|
|
13
|
-
method: 'GET',
|
|
14
|
-
url: `${prefix}/list`,
|
|
15
|
-
});
|
|
16
|
-
const rep = JSON.parse(res?.body);
|
|
17
|
-
assert.ok(rep.data);
|
|
18
|
-
});
|
|
19
|
-
let id;
|
|
20
|
-
await t.test('POST /list', async () => {
|
|
21
|
-
const res = await app.inject({
|
|
22
|
-
method: 'POST',
|
|
23
|
-
url: `${prefix}/list`,
|
|
24
|
-
body: { data: { key: 'testDB', name: 'testTitle', options: { database: 'mbk_kr_prod' } } },
|
|
25
|
-
});
|
|
26
|
-
const rep = JSON.parse(res?.body);
|
|
27
|
-
id = rep.data?.find((el) => el.key === 'testDB')?.id;
|
|
28
|
-
assert.ok(id);
|
|
29
|
-
});
|
|
30
|
-
await t.test('PUT /list/:id', async () => {
|
|
31
|
-
const res = await app.inject({
|
|
32
|
-
method: 'PUT',
|
|
33
|
-
url: `${prefix}/list/${id}`,
|
|
34
|
-
body: { data: { key: 'testDB1', name: 'testTitle1', options: { host: '192.168.3.160', database: 'mbk_kr_prod', port: 5434 } } },
|
|
35
|
-
});
|
|
36
|
-
const rep = JSON.parse(res?.body);
|
|
37
|
-
assert.ok(rep.data);
|
|
38
|
-
});
|
|
39
|
-
await t.test('DELETE /list/:id', async () => {
|
|
40
|
-
const res = await app.inject({
|
|
41
|
-
method: 'DELETE',
|
|
42
|
-
url: `${prefix}/list/${id}`,
|
|
43
|
-
});
|
|
44
|
-
const rep = JSON.parse(res?.body);
|
|
45
|
-
assert.ok(rep.data);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import build from '../../helper.js';
|
|
5
|
+
import config from '../config.js';
|
|
6
|
+
|
|
7
|
+
const prefix = config.prefix || '/api';
|
|
8
|
+
|
|
9
|
+
test('api dblist', async (t) => {
|
|
10
|
+
const app = await build(t);
|
|
11
|
+
await t.test('GET /list', async () => {
|
|
12
|
+
const res = await app.inject({
|
|
13
|
+
method: 'GET',
|
|
14
|
+
url: `${prefix}/list`,
|
|
15
|
+
});
|
|
16
|
+
const rep = JSON.parse(res?.body);
|
|
17
|
+
assert.ok(rep.data);
|
|
18
|
+
});
|
|
19
|
+
let id;
|
|
20
|
+
await t.test('POST /list', async () => {
|
|
21
|
+
const res = await app.inject({
|
|
22
|
+
method: 'POST',
|
|
23
|
+
url: `${prefix}/list`,
|
|
24
|
+
body: { data: { key: 'testDB', name: 'testTitle', options: { database: 'mbk_kr_prod' } } },
|
|
25
|
+
});
|
|
26
|
+
const rep = JSON.parse(res?.body);
|
|
27
|
+
id = rep.data?.find((el) => el.key === 'testDB')?.id;
|
|
28
|
+
assert.ok(id);
|
|
29
|
+
});
|
|
30
|
+
await t.test('PUT /list/:id', async () => {
|
|
31
|
+
const res = await app.inject({
|
|
32
|
+
method: 'PUT',
|
|
33
|
+
url: `${prefix}/list/${id}`,
|
|
34
|
+
body: { data: { key: 'testDB1', name: 'testTitle1', options: { host: '192.168.3.160', database: 'mbk_kr_prod', port: 5434 } } },
|
|
35
|
+
});
|
|
36
|
+
const rep = JSON.parse(res?.body);
|
|
37
|
+
assert.ok(rep.data);
|
|
38
|
+
});
|
|
39
|
+
await t.test('DELETE /list/:id', async () => {
|
|
40
|
+
const res = await app.inject({
|
|
41
|
+
method: 'DELETE',
|
|
42
|
+
url: `${prefix}/list/${id}`,
|
|
43
|
+
});
|
|
44
|
+
const rep = JSON.parse(res?.body);
|
|
45
|
+
assert.ok(rep.data);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import build from '../../helper.js';
|
|
5
|
-
import config from '../config.js';
|
|
6
|
-
|
|
7
|
-
const session = { passport: { user: { uid: config.testUser?.uid || '1' } } };
|
|
8
|
-
|
|
9
|
-
import userNotifications from '../../notification/controllers/userNotifications.js';
|
|
10
|
-
|
|
11
|
-
import pgClients from '../../pg/pgClients.js';
|
|
12
|
-
|
|
13
|
-
test('api && funcs notification', async (t) => {
|
|
14
|
-
const app = await build(t);
|
|
15
|
-
const pg = pgClients.client;
|
|
16
|
-
/*
|
|
17
|
-
// require dependency
|
|
18
|
-
await t.test('GET /auth', async () => {
|
|
19
|
-
const res = await app.inject({
|
|
20
|
-
method: 'GET',
|
|
21
|
-
url: `/api/login?username=${config.testUser?.username}&password=${config.testUser?.password}`,
|
|
22
|
-
});
|
|
23
|
-
assert.ok(res.statusCode);
|
|
24
|
-
});
|
|
25
|
-
await t.test('GET /notification', async () => {
|
|
26
|
-
const res = await app.inject({
|
|
27
|
-
method: 'GET',
|
|
28
|
-
url: '/api/notification',
|
|
29
|
-
});
|
|
30
|
-
const rep = JSON.parse(res?.body);
|
|
31
|
-
assert.ok(rep.time);
|
|
32
|
-
}); */
|
|
33
|
-
await t.test('GET /notification', async () => {
|
|
34
|
-
const rep = await userNotifications({ pg, session });
|
|
35
|
-
assert.ok(rep.time);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import build from '../../helper.js';
|
|
5
|
+
import config from '../config.js';
|
|
6
|
+
|
|
7
|
+
const session = { passport: { user: { uid: config.testUser?.uid || '1' } } };
|
|
8
|
+
|
|
9
|
+
import userNotifications from '../../notification/controllers/userNotifications.js';
|
|
10
|
+
|
|
11
|
+
import pgClients from '../../pg/pgClients.js';
|
|
12
|
+
|
|
13
|
+
test('api && funcs notification', async (t) => {
|
|
14
|
+
const app = await build(t);
|
|
15
|
+
const pg = pgClients.client;
|
|
16
|
+
/*
|
|
17
|
+
// require dependency
|
|
18
|
+
await t.test('GET /auth', async () => {
|
|
19
|
+
const res = await app.inject({
|
|
20
|
+
method: 'GET',
|
|
21
|
+
url: `/api/login?username=${config.testUser?.username}&password=${config.testUser?.password}`,
|
|
22
|
+
});
|
|
23
|
+
assert.ok(res.statusCode);
|
|
24
|
+
});
|
|
25
|
+
await t.test('GET /notification', async () => {
|
|
26
|
+
const res = await app.inject({
|
|
27
|
+
method: 'GET',
|
|
28
|
+
url: '/api/notification',
|
|
29
|
+
});
|
|
30
|
+
const rep = JSON.parse(res?.body);
|
|
31
|
+
assert.ok(rep.time);
|
|
32
|
+
}); */
|
|
33
|
+
await t.test('GET /notification', async () => {
|
|
34
|
+
const rep = await userNotifications({ pg, session });
|
|
35
|
+
assert.ok(rep.time);
|
|
36
|
+
});
|
|
37
|
+
});
|
package/test/api/table.test.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import build from '../../helper.js';
|
|
5
|
-
|
|
6
|
-
test('api table', async (t) => {
|
|
7
|
-
const app = await build(t);
|
|
8
|
-
// assert.ok(1);
|
|
9
|
-
await t.test('GET /suggest', async () => {
|
|
10
|
-
const res = await app.inject({
|
|
11
|
-
method: 'GET',
|
|
12
|
-
url: '/api/suggest/test.storage.data',
|
|
13
|
-
});
|
|
14
|
-
// console.log(res?.body);
|
|
15
|
-
const rep = JSON.parse(res?.body);
|
|
16
|
-
// console.log(rep.total);
|
|
17
|
-
assert.ok(rep.total);
|
|
18
|
-
});
|
|
19
|
-
await t.test('GET /data', async () => {
|
|
20
|
-
const res = await app.inject({
|
|
21
|
-
method: 'GET',
|
|
22
|
-
url: '/api/data/test.dataset.table',
|
|
23
|
-
});
|
|
24
|
-
// console.log(res);
|
|
25
|
-
const rep = JSON.parse(res?.body);
|
|
26
|
-
// console.log(rep.total);
|
|
27
|
-
assert.ok(rep.total);
|
|
28
|
-
});
|
|
29
|
-
await t.test('GET /search', async () => {
|
|
30
|
-
const res = await app.inject({
|
|
31
|
-
method: 'GET',
|
|
32
|
-
url: '/api/search?table=test.dataset.table&key=0',
|
|
33
|
-
});
|
|
34
|
-
const rep = JSON.parse(res?.body);
|
|
35
|
-
assert.ok(rep.total);
|
|
36
|
-
});
|
|
37
|
-
await t.test('GET /form', async () => {
|
|
38
|
-
const res = await app.inject({
|
|
39
|
-
method: 'GET',
|
|
40
|
-
url: '/api/form/test.dataset.form',
|
|
41
|
-
});
|
|
42
|
-
// console.log(res);
|
|
43
|
-
const rep = JSON.parse(res?.body);
|
|
44
|
-
// console.log(rep.total);
|
|
45
|
-
assert.ok(rep);
|
|
46
|
-
});
|
|
47
|
-
await t.test('GET /filter', async () => {
|
|
48
|
-
const res = await app.inject({
|
|
49
|
-
method: 'GET',
|
|
50
|
-
url: '/api/filter/test.dataset.table',
|
|
51
|
-
});
|
|
52
|
-
// console.log(res);
|
|
53
|
-
const rep = JSON.parse(res?.body);
|
|
54
|
-
// console.log(rep.total);
|
|
55
|
-
assert.ok(rep);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import build from '../../helper.js';
|
|
5
|
+
|
|
6
|
+
test('api table', async (t) => {
|
|
7
|
+
const app = await build(t);
|
|
8
|
+
// assert.ok(1);
|
|
9
|
+
await t.test('GET /suggest', async () => {
|
|
10
|
+
const res = await app.inject({
|
|
11
|
+
method: 'GET',
|
|
12
|
+
url: '/api/suggest/test.storage.data',
|
|
13
|
+
});
|
|
14
|
+
// console.log(res?.body);
|
|
15
|
+
const rep = JSON.parse(res?.body);
|
|
16
|
+
// console.log(rep.total);
|
|
17
|
+
assert.ok(rep.total);
|
|
18
|
+
});
|
|
19
|
+
await t.test('GET /data', async () => {
|
|
20
|
+
const res = await app.inject({
|
|
21
|
+
method: 'GET',
|
|
22
|
+
url: '/api/data/test.dataset.table',
|
|
23
|
+
});
|
|
24
|
+
// console.log(res);
|
|
25
|
+
const rep = JSON.parse(res?.body);
|
|
26
|
+
// console.log(rep.total);
|
|
27
|
+
assert.ok(rep.total);
|
|
28
|
+
});
|
|
29
|
+
await t.test('GET /search', async () => {
|
|
30
|
+
const res = await app.inject({
|
|
31
|
+
method: 'GET',
|
|
32
|
+
url: '/api/search?table=test.dataset.table&key=0',
|
|
33
|
+
});
|
|
34
|
+
const rep = JSON.parse(res?.body);
|
|
35
|
+
assert.ok(rep.total);
|
|
36
|
+
});
|
|
37
|
+
await t.test('GET /form', async () => {
|
|
38
|
+
const res = await app.inject({
|
|
39
|
+
method: 'GET',
|
|
40
|
+
url: '/api/form/test.dataset.form',
|
|
41
|
+
});
|
|
42
|
+
// console.log(res);
|
|
43
|
+
const rep = JSON.parse(res?.body);
|
|
44
|
+
// console.log(rep.total);
|
|
45
|
+
assert.ok(rep);
|
|
46
|
+
});
|
|
47
|
+
await t.test('GET /filter', async () => {
|
|
48
|
+
const res = await app.inject({
|
|
49
|
+
method: 'GET',
|
|
50
|
+
url: '/api/filter/test.dataset.table',
|
|
51
|
+
});
|
|
52
|
+
// console.log(res);
|
|
53
|
+
const rep = JSON.parse(res?.body);
|
|
54
|
+
// console.log(rep.total);
|
|
55
|
+
assert.ok(rep);
|
|
56
|
+
});
|
|
57
|
+
});
|
package/test/api/widget.test.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import build from '../../helper.js';
|
|
5
|
-
import config from '../config.js';
|
|
6
|
-
|
|
7
|
-
const session = { passport: { user: { uid: config.testUser?.uid || '1' } } };
|
|
8
|
-
|
|
9
|
-
import widgetGet from '../../widget/controllers/widget.get.js';
|
|
10
|
-
import widgetSet from '../../widget/controllers/widget.set.js';
|
|
11
|
-
import widgetDel from '../../widget/controllers/widget.del.js';
|
|
12
|
-
|
|
13
|
-
import pgClients from '../../pg/pgClients.js';
|
|
14
|
-
|
|
15
|
-
test('widget api', async (t) => {
|
|
16
|
-
await build(t);
|
|
17
|
-
const pg = pgClients.client;
|
|
18
|
-
await t.test('POST /widget/:type/:objectid', async () => {
|
|
19
|
-
const body = {};
|
|
20
|
-
const rep = await widgetSet({
|
|
21
|
-
pg, params: { type: 'comment', objectid: '1' }, session, body,
|
|
22
|
-
});
|
|
23
|
-
assert.ok(rep.data);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
let resp;
|
|
27
|
-
await t.test('GET /widget/:type/:objectid', async () => {
|
|
28
|
-
resp = await widgetGet({
|
|
29
|
-
pg, session, params: { type: 'comment', objectid: '1' },
|
|
30
|
-
});
|
|
31
|
-
assert.ok(resp.rows.length > 0, 'widget data get fail');
|
|
32
|
-
});
|
|
33
|
-
await t.test('DELETE /widget/:type/:objectid', async () => {
|
|
34
|
-
resp = await widgetDel({
|
|
35
|
-
pg, session, params: { type: 'comment', objectid: '1', id: resp.rows?.find((row) => row)?.comment_id },
|
|
36
|
-
});
|
|
37
|
-
assert.ok(resp.data.rowCount === 1, 'widget data delete fail');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import build from '../../helper.js';
|
|
5
|
+
import config from '../config.js';
|
|
6
|
+
|
|
7
|
+
const session = { passport: { user: { uid: config.testUser?.uid || '1' } } };
|
|
8
|
+
|
|
9
|
+
import widgetGet from '../../widget/controllers/widget.get.js';
|
|
10
|
+
import widgetSet from '../../widget/controllers/widget.set.js';
|
|
11
|
+
import widgetDel from '../../widget/controllers/widget.del.js';
|
|
12
|
+
|
|
13
|
+
import pgClients from '../../pg/pgClients.js';
|
|
14
|
+
|
|
15
|
+
test('widget api', async (t) => {
|
|
16
|
+
await build(t);
|
|
17
|
+
const pg = pgClients.client;
|
|
18
|
+
await t.test('POST /widget/:type/:objectid', async () => {
|
|
19
|
+
const body = {};
|
|
20
|
+
const rep = await widgetSet({
|
|
21
|
+
pg, params: { type: 'comment', objectid: '1' }, session, body,
|
|
22
|
+
});
|
|
23
|
+
assert.ok(rep.data);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
let resp;
|
|
27
|
+
await t.test('GET /widget/:type/:objectid', async () => {
|
|
28
|
+
resp = await widgetGet({
|
|
29
|
+
pg, session, params: { type: 'comment', objectid: '1' },
|
|
30
|
+
});
|
|
31
|
+
assert.ok(resp.rows.length > 0, 'widget data get fail');
|
|
32
|
+
});
|
|
33
|
+
await t.test('DELETE /widget/:type/:objectid', async () => {
|
|
34
|
+
resp = await widgetDel({
|
|
35
|
+
pg, session, params: { type: 'comment', objectid: '1', id: resp.rows?.find((row) => row)?.comment_id },
|
|
36
|
+
});
|
|
37
|
+
assert.ok(resp.data.rowCount === 1, 'widget data delete fail');
|
|
38
|
+
});
|
|
39
|
+
});
|
package/test/config.example
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import config from '../config.js';
|
|
2
|
-
|
|
3
|
-
Object.assign(config, {
|
|
4
|
-
templateDir: 'test/templates',
|
|
5
|
-
pg: {
|
|
6
|
-
host: '192.168.3.160',
|
|
7
|
-
port: 5434,
|
|
8
|
-
database: 'mbk_rivne_dma',
|
|
9
|
-
user: 'postgres',
|
|
10
|
-
password: 'postgres',
|
|
11
|
-
},
|
|
12
|
-
redis: {
|
|
13
|
-
host: '192.168.3.160',
|
|
14
|
-
port: 6379,
|
|
15
|
-
family: 4,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
export default config;
|
|
1
|
+
import config from '../config.js';
|
|
2
|
+
|
|
3
|
+
Object.assign(config, {
|
|
4
|
+
templateDir: 'test/templates',
|
|
5
|
+
pg: {
|
|
6
|
+
host: '192.168.3.160',
|
|
7
|
+
port: 5434,
|
|
8
|
+
database: 'mbk_rivne_dma',
|
|
9
|
+
user: 'postgres',
|
|
10
|
+
password: 'postgres',
|
|
11
|
+
},
|
|
12
|
+
redis: {
|
|
13
|
+
host: '192.168.3.160',
|
|
14
|
+
port: 6379,
|
|
15
|
+
family: 4,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export default config;
|