core-express 0.1.0 → 0.1.1
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 +1 -1
- package/lib/GenericController.js +224 -131
- package/lib/GenericSearchController.js +58 -37
- package/lib/HealthController.js +16 -58
- package/lib/LoadController.js +71 -46
- package/lib/LoadSearchController.js +113 -41
- package/lib/LogController.js +89 -0
- package/lib/LowCodeController.js +100 -0
- package/lib/SearchController.js +32 -25
- package/lib/access.js +34 -0
- package/lib/client.js +80 -0
- package/lib/edit.js +99 -84
- package/lib/health.js +157 -76
- package/lib/http.js +316 -0
- package/lib/index.js +488 -16
- package/lib/log.js +242 -0
- package/lib/resources.js +106 -6
- package/lib/search.js +766 -160
- package/lib/view.js +48 -34
- package/package.json +8 -4
- package/src/GenericController.ts +217 -106
- package/src/GenericSearchController.ts +38 -21
- package/src/HealthController.ts +9 -9
- package/src/LoadController.ts +70 -40
- package/src/LoadSearchController.ts +114 -21
- package/src/LogController.ts +137 -0
- package/src/LowCodeController.ts +88 -0
- package/src/SearchController.ts +28 -17
- package/src/access.ts +42 -0
- package/src/client.ts +69 -0
- package/src/edit.ts +93 -61
- package/src/health.ts +27 -28
- package/src/http.ts +295 -0
- package/src/index.ts +464 -13
- package/src/log.ts +245 -0
- package/src/metadata.ts +34 -23
- package/src/resources.ts +143 -4
- package/src/search.ts +782 -198
- package/src/view.ts +44 -30
- package/tsconfig.json +1 -0
- package/lib/response.js +0 -12
- package/src/response.ts +0 -10
package/lib/index.js
CHANGED
|
@@ -1,17 +1,489 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict"
|
|
2
2
|
function __export(m) {
|
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]
|
|
4
|
-
}
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]
|
|
4
|
+
}
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
6
|
+
var GenericController_1 = require("./GenericController")
|
|
7
|
+
exports.GenericHandler = GenericController_1.GenericController
|
|
8
|
+
var GenericSearchController_1 = require("./GenericSearchController")
|
|
9
|
+
exports.GenericSearchHandler = GenericSearchController_1.GenericSearchController
|
|
10
|
+
var HealthController_1 = require("./HealthController")
|
|
11
|
+
exports.HealthHandler = HealthController_1.HealthController
|
|
12
|
+
var http_1 = require("./http")
|
|
13
|
+
var LoadController_1 = require("./LoadController")
|
|
14
|
+
exports.LoadHandler = LoadController_1.LoadController
|
|
15
|
+
exports.ViewHandler = LoadController_1.LoadController
|
|
16
|
+
var LoadSearchController_1 = require("./LoadSearchController")
|
|
17
|
+
exports.LoadSearchHandler = LoadSearchController_1.LoadSearchController
|
|
18
|
+
var LogController_1 = require("./LogController")
|
|
19
|
+
exports.LogHandler = LogController_1.LogController
|
|
20
|
+
var LowCodeController_1 = require("./LowCodeController")
|
|
21
|
+
exports.Handler = LowCodeController_1.Controller
|
|
22
|
+
var resources_1 = require("./resources")
|
|
23
|
+
var SearchController_1 = require("./SearchController")
|
|
24
|
+
exports.SearchHandler = SearchController_1.SearchController
|
|
25
|
+
__export(require("./access"))
|
|
26
|
+
__export(require("./client"))
|
|
27
|
+
__export(require("./edit"))
|
|
28
|
+
__export(require("./GenericController"))
|
|
29
|
+
__export(require("./GenericSearchController"))
|
|
30
|
+
__export(require("./health"))
|
|
31
|
+
__export(require("./HealthController"))
|
|
32
|
+
__export(require("./http"))
|
|
33
|
+
__export(require("./LoadController"))
|
|
34
|
+
__export(require("./LoadSearchController"))
|
|
35
|
+
__export(require("./log"))
|
|
36
|
+
__export(require("./LogController"))
|
|
37
|
+
__export(require("./LowCodeController"))
|
|
38
|
+
__export(require("./resources"))
|
|
39
|
+
__export(require("./search"))
|
|
40
|
+
__export(require("./SearchController"))
|
|
41
|
+
__export(require("./view"))
|
|
42
|
+
var SavedController = (function () {
|
|
43
|
+
function SavedController(savedService, id, userId) {
|
|
44
|
+
this.savedService = savedService
|
|
45
|
+
this.userId = userId && userId.length > 0 ? userId : "userId"
|
|
46
|
+
this.id = id && id.length > 0 ? id : "id"
|
|
47
|
+
this.save = this.save.bind(this)
|
|
48
|
+
this.remove = this.remove.bind(this)
|
|
49
|
+
}
|
|
50
|
+
SavedController.prototype.save = function (req, res) {
|
|
51
|
+
var userId = res.locals[this.userId]
|
|
52
|
+
var id = req.params[this.id]
|
|
53
|
+
if (!id || id.length === 0) {
|
|
54
|
+
res.status(400).end("'" + this.id + "' cannot be empty")
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
if (!userId || userId.length === 0) {
|
|
58
|
+
res.status(400).end("'" + this.userId + "' cannot be empty")
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
this.savedService
|
|
62
|
+
.save(userId, id)
|
|
63
|
+
.then(function (result) {
|
|
64
|
+
var status = result > 0 ? 200 : result === 0 ? 409 : 422
|
|
65
|
+
res.status(status).json(result).end()
|
|
66
|
+
})
|
|
67
|
+
.catch(function (err) {
|
|
68
|
+
return http_1.handleError(err, res)
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
SavedController.prototype.remove = function (req, res) {
|
|
72
|
+
var userId = res.locals[this.userId]
|
|
73
|
+
var id = req.params[this.id]
|
|
74
|
+
if (!id || id.length === 0) {
|
|
75
|
+
res.status(400).end("'" + this.id + "' cannot be empty")
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
if (!userId || userId.length === 0) {
|
|
79
|
+
res.status(400).end("'" + this.userId + "' cannot be empty")
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
this.savedService
|
|
83
|
+
.remove(userId, id)
|
|
84
|
+
.then(function (result) {
|
|
85
|
+
var status = result > 0 ? 200 : 410
|
|
86
|
+
res.status(status).json(result).end()
|
|
87
|
+
})
|
|
88
|
+
.catch(function (err) {
|
|
89
|
+
return http_1.handleError(err, res)
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
return SavedController
|
|
93
|
+
})()
|
|
94
|
+
exports.SavedController = SavedController
|
|
95
|
+
var FollowController = (function () {
|
|
96
|
+
function FollowController(service, id, userId) {
|
|
97
|
+
this.service = service
|
|
98
|
+
this.userId = userId && userId.length > 0 ? userId : "userId"
|
|
99
|
+
this.id = id && id.length > 0 ? id : "id"
|
|
100
|
+
this.follow = this.follow.bind(this)
|
|
101
|
+
this.unfollow = this.unfollow.bind(this)
|
|
102
|
+
}
|
|
103
|
+
FollowController.prototype.follow = function (req, res) {
|
|
104
|
+
var userId = res.locals[this.userId]
|
|
105
|
+
var id = req.params[this.id]
|
|
106
|
+
if (!id || id.length === 0) {
|
|
107
|
+
res.status(400).end("'" + this.id + "' cannot be empty")
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
if (!userId || userId.length === 0) {
|
|
111
|
+
res.status(400).end("'" + this.userId + "' cannot be empty")
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
this.service
|
|
115
|
+
.follow(userId, id)
|
|
116
|
+
.then(function (result) {
|
|
117
|
+
var status = result > 0 ? 200 : 409
|
|
118
|
+
res.status(status).json(result).end()
|
|
119
|
+
})
|
|
120
|
+
.catch(function (err) {
|
|
121
|
+
return http_1.handleError(err, res)
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
FollowController.prototype.unfollow = function (req, res) {
|
|
125
|
+
var userId = res.locals[this.userId]
|
|
126
|
+
var id = req.params[this.id]
|
|
127
|
+
if (!id || id.length === 0) {
|
|
128
|
+
res.status(400).end("'" + this.id + "' cannot be empty")
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
if (!userId || userId.length === 0) {
|
|
132
|
+
res.status(400).end("'" + this.userId + "' cannot be empty")
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
this.service
|
|
136
|
+
.unfollow(userId, id)
|
|
137
|
+
.then(function (result) {
|
|
138
|
+
var status = result > 0 ? 200 : 410
|
|
139
|
+
res.status(status).json(result).end()
|
|
140
|
+
})
|
|
141
|
+
.catch(function (err) {
|
|
142
|
+
return http_1.handleError(err, res)
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
return FollowController
|
|
146
|
+
})()
|
|
147
|
+
exports.FollowController = FollowController
|
|
148
|
+
var UserReactionController = (function () {
|
|
149
|
+
function UserReactionController(service, author, id, reaction) {
|
|
150
|
+
this.service = service
|
|
151
|
+
this.author = author
|
|
152
|
+
this.reaction = reaction
|
|
153
|
+
this.id = id && id.length > 0 ? id : "id"
|
|
154
|
+
this.react = this.react.bind(this)
|
|
155
|
+
this.unreact = this.unreact.bind(this)
|
|
156
|
+
this.checkReaction = this.checkReaction.bind(this)
|
|
157
|
+
}
|
|
158
|
+
UserReactionController.prototype.react = function (req, res) {
|
|
159
|
+
var id = req.params.id
|
|
160
|
+
var author = req.params.author
|
|
161
|
+
var reaction = req.params.reaction
|
|
162
|
+
if (!id || id.length === 0) {
|
|
163
|
+
res.status(400).end("'" + this.id + "' cannot be empty")
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
if (!author || author.length === 0) {
|
|
167
|
+
res.status(400).end("'" + this.author + "' cannot be empty")
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
if (!reaction || reaction.length === 0) {
|
|
171
|
+
res.status(400).end("'" + this.reaction + "' cannot be empty")
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
this.service
|
|
175
|
+
.react(id, author, reaction)
|
|
176
|
+
.then(function (count) {
|
|
177
|
+
res.status(200).json(count).end()
|
|
178
|
+
})
|
|
179
|
+
.catch(function (err) {
|
|
180
|
+
return http_1.handleError(err, res)
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
UserReactionController.prototype.unreact = function (req, res) {
|
|
184
|
+
var id = req.params.id
|
|
185
|
+
var author = req.params.author
|
|
186
|
+
var reaction = req.params.reaction
|
|
187
|
+
if (!id || id.length === 0) {
|
|
188
|
+
res.status(400).end("'" + this.id + "' cannot be empty")
|
|
189
|
+
return
|
|
190
|
+
}
|
|
191
|
+
if (!author || author.length === 0) {
|
|
192
|
+
res.status(400).end("'" + this.author + "' cannot be empty")
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
if (!reaction || reaction.length === 0) {
|
|
196
|
+
res.status(400).end("'" + this.reaction + "' cannot be empty")
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
this.service
|
|
200
|
+
.unreact(id, author, reaction)
|
|
201
|
+
.then(function (count) {
|
|
202
|
+
res.status(200).json(count).end()
|
|
203
|
+
})
|
|
204
|
+
.catch(function (err) {
|
|
205
|
+
return http_1.handleError(err, res)
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
UserReactionController.prototype.checkReaction = function (req, res) {
|
|
209
|
+
var id = req.params.id
|
|
210
|
+
var author = req.params.author
|
|
211
|
+
if (!id || id.length === 0) {
|
|
212
|
+
res.status(400).end("'" + this.id + "' cannot be empty")
|
|
213
|
+
return
|
|
214
|
+
}
|
|
215
|
+
if (!author || author.length === 0) {
|
|
216
|
+
res.status(400).end("'" + this.author + "' cannot be empty")
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
this.service
|
|
220
|
+
.checkReaction(id, author)
|
|
221
|
+
.then(function (count) {
|
|
222
|
+
res.status(200).json(count).end()
|
|
223
|
+
})
|
|
224
|
+
.catch(function (err) {
|
|
225
|
+
return http_1.handleError(err, res)
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
return UserReactionController
|
|
229
|
+
})()
|
|
230
|
+
exports.UserReactionController = UserReactionController
|
|
231
|
+
exports.ReactController = UserReactionController
|
|
232
|
+
exports.ReactionController = UserReactionController
|
|
233
|
+
function checked(s, v) {
|
|
234
|
+
if (s) {
|
|
235
|
+
if (Array.isArray(s)) {
|
|
236
|
+
return s.includes(v)
|
|
237
|
+
} else {
|
|
238
|
+
return s === v
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return false
|
|
242
|
+
}
|
|
243
|
+
exports.checked = checked
|
|
244
|
+
function addSeconds(date, number) {
|
|
245
|
+
var d = new Date(date)
|
|
246
|
+
d.setSeconds(d.getSeconds() + number)
|
|
247
|
+
return d
|
|
248
|
+
}
|
|
249
|
+
exports.addSeconds = addSeconds
|
|
250
|
+
function addMinutes(date, number) {
|
|
251
|
+
var d = new Date(date)
|
|
252
|
+
d.setMinutes(d.getMinutes() + number)
|
|
253
|
+
return d
|
|
254
|
+
}
|
|
255
|
+
exports.addMinutes = addMinutes
|
|
256
|
+
function addDays(d, n) {
|
|
257
|
+
var newDate = new Date(d)
|
|
258
|
+
newDate.setDate(newDate.getDate() + n)
|
|
259
|
+
return newDate
|
|
260
|
+
}
|
|
261
|
+
exports.addDays = addDays
|
|
262
|
+
function toMap(errors) {
|
|
263
|
+
var errorMap = {}
|
|
264
|
+
if (!errors) {
|
|
265
|
+
return errorMap
|
|
266
|
+
}
|
|
267
|
+
for (var i = 0; i < errors.length; i++) {
|
|
268
|
+
errors[i].invalid = "invalid"
|
|
269
|
+
errorMap[errors[i].field] = errors[i]
|
|
270
|
+
}
|
|
271
|
+
return errorMap
|
|
272
|
+
}
|
|
273
|
+
exports.toMap = toMap
|
|
274
|
+
function isSuccessful(res) {
|
|
275
|
+
return (typeof res === "number" && res <= 0) || Array.isArray(res) ? false : true
|
|
276
|
+
}
|
|
277
|
+
exports.isSuccessful = isSuccessful
|
|
278
|
+
function afterCreated(res, result, returnObject) {
|
|
279
|
+
if (Array.isArray(result)) {
|
|
280
|
+
res.status(422).json(result).end()
|
|
281
|
+
} else if (typeof result === "number") {
|
|
282
|
+
if (result > 0) {
|
|
283
|
+
res.status(200).json(result).end()
|
|
284
|
+
} else {
|
|
285
|
+
res.status(409).json(result).end()
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
res
|
|
289
|
+
.status(201)
|
|
290
|
+
.json(returnObject ? result : 1)
|
|
291
|
+
.end()
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
exports.afterCreated = afterCreated
|
|
295
|
+
function respond(res, result, returnObject) {
|
|
296
|
+
if (Array.isArray(result)) {
|
|
297
|
+
res.status(422).json(result).end()
|
|
298
|
+
} else if (typeof result === "number") {
|
|
299
|
+
if (result > 0) {
|
|
300
|
+
res.status(200).json(result).end()
|
|
301
|
+
} else if (result === 0) {
|
|
302
|
+
res.status(410).json(result).end()
|
|
303
|
+
} else {
|
|
304
|
+
res.status(409).json(result).end()
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
res
|
|
308
|
+
.status(200)
|
|
309
|
+
.json(returnObject ? result : 1)
|
|
310
|
+
.end()
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
exports.respond = respond
|
|
314
|
+
function save(isEdit, res, obj, service, returnNumber) {
|
|
315
|
+
if (!isEdit) {
|
|
316
|
+
service
|
|
317
|
+
.create(obj)
|
|
318
|
+
.then(function (result) {
|
|
319
|
+
if (Array.isArray(result)) {
|
|
320
|
+
res.status(422).json(result).end()
|
|
321
|
+
} else if (typeof result === "number" && result <= 0) {
|
|
322
|
+
res.status(409).json(result).end()
|
|
323
|
+
} else {
|
|
324
|
+
res.status(201).json(obj).end()
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
.catch(function (err) {
|
|
328
|
+
return http_1.handleError(err, res)
|
|
329
|
+
})
|
|
330
|
+
} else {
|
|
331
|
+
service
|
|
332
|
+
.update(obj)
|
|
333
|
+
.then(function (result) {
|
|
334
|
+
if (result === 0) {
|
|
335
|
+
res.status(410).end()
|
|
336
|
+
} else if (Array.isArray(result)) {
|
|
337
|
+
res.status(422).json(result).end()
|
|
338
|
+
} else if (typeof result === "number" && result < 0) {
|
|
339
|
+
res.status(409).json(result).end()
|
|
340
|
+
} else {
|
|
341
|
+
res
|
|
342
|
+
.status(200)
|
|
343
|
+
.json(returnNumber ? result : obj)
|
|
344
|
+
.end()
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
.catch(function (err) {
|
|
348
|
+
return http_1.handleError(err, res)
|
|
349
|
+
})
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
exports.save = save
|
|
353
|
+
var map = {
|
|
354
|
+
"&": "&",
|
|
355
|
+
"<": "<",
|
|
356
|
+
">": ">",
|
|
357
|
+
'"': """,
|
|
358
|
+
"'": "'",
|
|
359
|
+
"`": "`",
|
|
360
|
+
}
|
|
361
|
+
function escapeHTML(input) {
|
|
362
|
+
return input.replace(/[&<>"'`]/g, function (char) {
|
|
363
|
+
return map[char]
|
|
364
|
+
})
|
|
365
|
+
}
|
|
366
|
+
exports.escapeHTML = escapeHTML
|
|
367
|
+
function generateChip(value, text, noClose, hasStar) {
|
|
368
|
+
var s = noClose ? "" : '<span class="close" onclick="removeChip(event)"></span>'
|
|
369
|
+
var t = hasStar ? '<i class="star highlight"></i>' : ""
|
|
370
|
+
return '<div class="chip" data-value="' + escapeHTML(value) + '">' + escapeHTML(text) + t + s + "</div>"
|
|
371
|
+
}
|
|
372
|
+
exports.generateChip = generateChip
|
|
373
|
+
function generateTags(v, noClose) {
|
|
374
|
+
return !v
|
|
375
|
+
? ""
|
|
376
|
+
: "" +
|
|
377
|
+
v
|
|
378
|
+
.map(function (s) {
|
|
379
|
+
return generateChip(s, s, noClose)
|
|
380
|
+
})
|
|
381
|
+
.join("")
|
|
382
|
+
}
|
|
383
|
+
exports.generateTags = generateTags
|
|
384
|
+
function generateChips(v, noClose) {
|
|
385
|
+
return !v
|
|
386
|
+
? ""
|
|
387
|
+
: "" +
|
|
388
|
+
v
|
|
389
|
+
.map(function (s) {
|
|
390
|
+
return generateChip(s.value, s.text, noClose)
|
|
391
|
+
})
|
|
392
|
+
.join("")
|
|
393
|
+
}
|
|
394
|
+
exports.generateChips = generateChips
|
|
395
|
+
function generateStarChips(v, value, text, star, noClose) {
|
|
396
|
+
return !v
|
|
397
|
+
? ""
|
|
398
|
+
: "" +
|
|
399
|
+
v
|
|
400
|
+
.map(function (s) {
|
|
401
|
+
return generateChip(s[value], s[text], noClose, s[star] === true)
|
|
402
|
+
})
|
|
403
|
+
.join("")
|
|
404
|
+
}
|
|
405
|
+
exports.generateStarChips = generateStarChips
|
|
406
|
+
var s = "string"
|
|
407
|
+
var o = "object"
|
|
408
|
+
function escape(obj) {
|
|
409
|
+
if (!obj || typeof obj !== s) {
|
|
410
|
+
return obj
|
|
411
|
+
}
|
|
412
|
+
var keys = Object.keys(obj)
|
|
413
|
+
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
414
|
+
var key = keys_1[_i]
|
|
415
|
+
var v = obj[key]
|
|
416
|
+
if (typeof v === s) {
|
|
417
|
+
obj[key] = escapeHTML(v)
|
|
418
|
+
} else if (Array.isArray(v) && v.length > 0) {
|
|
419
|
+
var v1 = v[0]
|
|
420
|
+
if (typeof v1 === o && !(v1 instanceof Date)) {
|
|
421
|
+
for (var _a = 0, v_1 = v; _a < v_1.length; _a++) {
|
|
422
|
+
var item = v_1[_a]
|
|
423
|
+
escape(item)
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
} else if (typeof v === o && !(v instanceof Date)) {
|
|
427
|
+
escape(obj[key])
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return obj
|
|
431
|
+
}
|
|
432
|
+
exports.escape = escape
|
|
433
|
+
function escapeArray(arrs, offset, name) {
|
|
434
|
+
if (offset === void 0) {
|
|
435
|
+
offset = 0
|
|
436
|
+
}
|
|
437
|
+
if (!arrs) {
|
|
438
|
+
return arrs
|
|
439
|
+
}
|
|
440
|
+
if (arrs.length > 0) {
|
|
441
|
+
for (var _i = 0, arrs_1 = arrs; _i < arrs_1.length; _i++) {
|
|
442
|
+
var obj = arrs_1[_i]
|
|
443
|
+
escape(obj)
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
if (name) {
|
|
447
|
+
var l = arrs.length
|
|
448
|
+
for (var i = 0; i < l; i++) {
|
|
449
|
+
arrs[i][name] = offset + i + 1
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return arrs
|
|
453
|
+
}
|
|
454
|
+
exports.escapeArray = escapeArray
|
|
455
|
+
function buildError404(resource, res) {
|
|
456
|
+
return {
|
|
457
|
+
message: {
|
|
458
|
+
title: resource.error_404_title,
|
|
459
|
+
description: resource.error_404_message,
|
|
460
|
+
},
|
|
461
|
+
menu: res.locals.menu,
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
exports.buildError404 = buildError404
|
|
465
|
+
function buildError500(resource, res) {
|
|
466
|
+
return {
|
|
467
|
+
message: {
|
|
468
|
+
title: resource.error_500_title,
|
|
469
|
+
description: resource.error_500_message,
|
|
470
|
+
},
|
|
471
|
+
menu: res.locals.menu,
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
exports.buildError500 = buildError500
|
|
475
|
+
function buildError(res, title, description) {
|
|
476
|
+
return {
|
|
477
|
+
message: {
|
|
478
|
+
title: title,
|
|
479
|
+
description: description,
|
|
480
|
+
},
|
|
481
|
+
menu: res.locals.menu,
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
exports.buildError = buildError
|
|
485
|
+
function queryLang(req) {
|
|
486
|
+
var lang = http_1.query(req, resources_1.resources.languageParam)
|
|
487
|
+
return lang && lang.length > 0 ? lang : resources_1.resources.defaultLanguage
|
|
488
|
+
}
|
|
489
|
+
exports.queryLang = queryLang
|