express-ext 0.4.0 → 0.4.2
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/lib/GenericSearchController.js +38 -41
- package/lib/LoadSearchController.js +73 -80
- package/lib/LowCodeController.js +61 -68
- package/lib/SearchController.js +26 -29
- package/lib/index.js +278 -242
- package/lib/resources.js +60 -56
- package/lib/search.js +348 -477
- package/package.json +1 -1
- package/src/GenericController.ts +101 -101
- package/src/GenericSearchController.ts +25 -30
- package/src/HealthController.ts +8 -8
- package/src/LoadController.ts +55 -48
- package/src/LoadSearchController.ts +63 -72
- package/src/LogController.ts +86 -84
- package/src/LowCodeController.ts +44 -54
- package/src/SearchController.ts +19 -23
- package/src/client.ts +46 -46
- package/src/edit.ts +45 -45
- package/src/health.ts +26 -26
- package/src/http.ts +139 -139
- package/src/index.ts +229 -197
- package/src/log.ts +155 -151
- package/src/metadata.ts +44 -27
- package/src/resources.ts +73 -69
- package/src/search.ts +342 -502
- package/src/view.ts +33 -33
package/src/view.ts
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import {Request, Response} from
|
|
2
|
-
import {Attribute, Attributes} from
|
|
1
|
+
import { Request, Response } from "express"
|
|
2
|
+
import { Attribute, Attributes } from "./metadata"
|
|
3
3
|
|
|
4
4
|
export function buildAndCheckId<ID>(req: Request, res: Response, keys?: Attribute[]): ID | undefined {
|
|
5
|
-
const id = buildId<ID>(req, keys)
|
|
5
|
+
const id = buildId<ID>(req, keys)
|
|
6
6
|
if (!id) {
|
|
7
|
-
res.status(400).end(
|
|
8
|
-
return undefined
|
|
7
|
+
res.status(400).end("invalid parameters")
|
|
8
|
+
return undefined
|
|
9
9
|
}
|
|
10
|
-
return id
|
|
10
|
+
return id
|
|
11
11
|
}
|
|
12
12
|
export function buildId<T>(req: Request, attrs?: Attribute[]): T | undefined {
|
|
13
13
|
if (!attrs || attrs.length === 0) {
|
|
14
|
-
const id = req.params[
|
|
14
|
+
const id = req.params["id"]
|
|
15
15
|
if (id && id.length > 0) {
|
|
16
|
-
return id as any
|
|
16
|
+
return id as any
|
|
17
17
|
}
|
|
18
|
-
return undefined
|
|
18
|
+
return undefined
|
|
19
19
|
}
|
|
20
20
|
if (attrs && attrs.length === 1) {
|
|
21
|
-
let id = req.params[
|
|
22
|
-
const n = attrs[0].name
|
|
21
|
+
let id = req.params["id"]
|
|
22
|
+
const n = attrs[0].name
|
|
23
23
|
if ((!id || id.length === 0) && n && n.length > 0) {
|
|
24
|
-
id = req.params[n]
|
|
24
|
+
id = req.params[n]
|
|
25
25
|
}
|
|
26
26
|
if (id && id.length > 0) {
|
|
27
|
-
if (attrs[0].type ===
|
|
27
|
+
if (attrs[0].type === "integer" || attrs[0].type === "number") {
|
|
28
28
|
if (isNaN(id as any)) {
|
|
29
|
-
return undefined
|
|
29
|
+
return undefined
|
|
30
30
|
}
|
|
31
|
-
const v = parseFloat(id)
|
|
32
|
-
return v as any
|
|
31
|
+
const v = parseFloat(id)
|
|
32
|
+
return v as any
|
|
33
33
|
}
|
|
34
|
-
return id as any
|
|
34
|
+
return id as any
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
const ids: any = {}
|
|
37
|
+
const ids: any = {}
|
|
38
38
|
for (const attr of attrs) {
|
|
39
39
|
if (!attr.name) {
|
|
40
|
-
return undefined
|
|
40
|
+
return undefined
|
|
41
41
|
}
|
|
42
|
-
const v = req.params[attr.name]
|
|
42
|
+
const v = req.params[attr.name]
|
|
43
43
|
if (!v) {
|
|
44
|
-
return undefined
|
|
44
|
+
return undefined
|
|
45
45
|
}
|
|
46
|
-
if (attr.type ===
|
|
46
|
+
if (attr.type === "integer" || attr.type === "number") {
|
|
47
47
|
if (isNaN(v as any)) {
|
|
48
|
-
return undefined
|
|
48
|
+
return undefined
|
|
49
49
|
}
|
|
50
|
-
ids[attr.name] = parseFloat(v)
|
|
50
|
+
ids[attr.name] = parseFloat(v)
|
|
51
51
|
} else {
|
|
52
|
-
ids[attr.name] = v
|
|
52
|
+
ids[attr.name] = v
|
|
53
53
|
}
|
|
54
|
-
return ids
|
|
54
|
+
return ids
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
export function buildKeys(attrs: Attributes): Attribute[] | undefined {
|
|
58
58
|
if (!attrs) {
|
|
59
|
-
return undefined
|
|
59
|
+
return undefined
|
|
60
60
|
}
|
|
61
|
-
const keys: string[] = Object.keys(attrs)
|
|
62
|
-
const ats: Attribute[] = []
|
|
61
|
+
const keys: string[] = Object.keys(attrs)
|
|
62
|
+
const ats: Attribute[] = []
|
|
63
63
|
for (const key of keys) {
|
|
64
|
-
const attr: Attribute = attrs[key]
|
|
64
|
+
const attr: Attribute = attrs[key]
|
|
65
65
|
if (attr) {
|
|
66
66
|
if (attr.key === true) {
|
|
67
|
-
const at: Attribute = {name: key, type: attr.type}
|
|
68
|
-
ats.push(at)
|
|
67
|
+
const at: Attribute = { name: key, type: attr.type }
|
|
68
|
+
ats.push(at)
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
return ats
|
|
72
|
+
return ats
|
|
73
73
|
}
|