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