express-ext 0.2.3 → 0.2.5
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 +37 -23
- package/lib/LoadSearchController.js +48 -31
- package/lib/LowCodeController.js +47 -27
- package/lib/SearchController.js +13 -10
- package/lib/http.js +9 -15
- package/lib/index.js +107 -66
- package/lib/search.js +149 -79
- package/package.json +1 -1
- package/src/GenericSearchController.ts +19 -10
- package/src/LoadSearchController.ts +37 -19
- package/src/LowCodeController.ts +34 -16
- package/src/SearchController.ts +13 -7
- package/src/http.ts +7 -7
- package/src/index.ts +88 -66
- package/src/search.ts +122 -36
package/lib/index.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
function __export(m) {
|
|
3
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(
|
|
5
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
|
+
var GenericController_1 = require('./GenericController');
|
|
7
7
|
exports.GenericHandler = GenericController_1.GenericController;
|
|
8
|
-
var GenericSearchController_1 = require(
|
|
8
|
+
var GenericSearchController_1 = require('./GenericSearchController');
|
|
9
9
|
exports.GenericSearchHandler = GenericSearchController_1.GenericSearchController;
|
|
10
|
-
var HealthController_1 = require(
|
|
10
|
+
var HealthController_1 = require('./HealthController');
|
|
11
11
|
exports.HealthHandler = HealthController_1.HealthController;
|
|
12
|
-
var http_1 = require(
|
|
13
|
-
var LoadController_1 = require(
|
|
12
|
+
var http_1 = require('./http');
|
|
13
|
+
var LoadController_1 = require('./LoadController');
|
|
14
14
|
exports.LoadHandler = LoadController_1.LoadController;
|
|
15
15
|
exports.ViewHandler = LoadController_1.LoadController;
|
|
16
|
-
var LoadSearchController_1 = require(
|
|
16
|
+
var LoadSearchController_1 = require('./LoadSearchController');
|
|
17
17
|
exports.LoadSearchHandler = LoadSearchController_1.LoadSearchController;
|
|
18
|
-
var LogController_1 = require(
|
|
18
|
+
var LogController_1 = require('./LogController');
|
|
19
19
|
exports.LogHandler = LogController_1.LogController;
|
|
20
|
-
var LowCodeController_1 = require(
|
|
20
|
+
var LowCodeController_1 = require('./LowCodeController');
|
|
21
21
|
exports.Handler = LowCodeController_1.Controller;
|
|
22
|
-
var SearchController_1 = require(
|
|
22
|
+
var SearchController_1 = require('./SearchController');
|
|
23
23
|
exports.SearchHandler = SearchController_1.SearchController;
|
|
24
|
-
__export(require(
|
|
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(
|
|
40
|
-
__export(require(
|
|
24
|
+
__export(require('./client'));
|
|
25
|
+
__export(require('./edit'));
|
|
26
|
+
__export(require('./GenericController'));
|
|
27
|
+
__export(require('./GenericSearchController'));
|
|
28
|
+
__export(require('./health'));
|
|
29
|
+
__export(require('./HealthController'));
|
|
30
|
+
__export(require('./http'));
|
|
31
|
+
__export(require('./LoadController'));
|
|
32
|
+
__export(require('./LoadSearchController'));
|
|
33
|
+
__export(require('./log'));
|
|
34
|
+
__export(require('./LogController'));
|
|
35
|
+
__export(require('./LowCodeController'));
|
|
36
|
+
__export(require('./resources'));
|
|
37
|
+
__export(require('./search'));
|
|
38
|
+
__export(require('./search_func'));
|
|
39
|
+
__export(require('./SearchController'));
|
|
40
|
+
__export(require('./view'));
|
|
41
41
|
function allow(access) {
|
|
42
42
|
var ao = access.origin;
|
|
43
43
|
if (typeof ao === 'string') {
|
|
@@ -48,8 +48,7 @@ function allow(access) {
|
|
|
48
48
|
res.setHeader('Access-Control-Allow-Headers', access.headers);
|
|
49
49
|
next();
|
|
50
50
|
};
|
|
51
|
-
}
|
|
52
|
-
else if (Array.isArray(ao) && ao.length > 0) {
|
|
51
|
+
} else if (Array.isArray(ao) && ao.length > 0) {
|
|
53
52
|
return function (req, res, next) {
|
|
54
53
|
var origin = req.headers.origin;
|
|
55
54
|
if (origin) {
|
|
@@ -76,7 +75,7 @@ var SavedController = (function () {
|
|
|
76
75
|
this.log = log;
|
|
77
76
|
this.service = service;
|
|
78
77
|
this.item = item;
|
|
79
|
-
this.id =
|
|
78
|
+
this.id = id && id.length > 0 ? id : 'id';
|
|
80
79
|
this.save = this.save.bind(this);
|
|
81
80
|
this.remove = this.remove.bind(this);
|
|
82
81
|
this.load = this.load.bind(this);
|
|
@@ -93,10 +92,14 @@ var SavedController = (function () {
|
|
|
93
92
|
res.status(400).end("'" + this.item + "' cannot be empty");
|
|
94
93
|
return;
|
|
95
94
|
}
|
|
96
|
-
this.service
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
this.service
|
|
96
|
+
.save(id, itemId)
|
|
97
|
+
.then(function (data) {
|
|
98
|
+
res.status(200).json(data).end();
|
|
99
|
+
})
|
|
100
|
+
.catch(function (err) {
|
|
101
|
+
return http_1.handleError(err, res, _this.log);
|
|
102
|
+
});
|
|
100
103
|
};
|
|
101
104
|
SavedController.prototype.remove = function (req, res) {
|
|
102
105
|
var _this = this;
|
|
@@ -110,10 +113,14 @@ var SavedController = (function () {
|
|
|
110
113
|
res.status(400).end("'" + this.item + "' cannot be empty");
|
|
111
114
|
return;
|
|
112
115
|
}
|
|
113
|
-
this.service
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
this.service
|
|
117
|
+
.remove(id, itemId)
|
|
118
|
+
.then(function (data) {
|
|
119
|
+
res.status(200).json(data).end();
|
|
120
|
+
})
|
|
121
|
+
.catch(function (err) {
|
|
122
|
+
return http_1.handleError(err, res, _this.log);
|
|
123
|
+
});
|
|
117
124
|
};
|
|
118
125
|
SavedController.prototype.load = function (req, res) {
|
|
119
126
|
var _this = this;
|
|
@@ -122,20 +129,24 @@ var SavedController = (function () {
|
|
|
122
129
|
res.status(400).end("'" + this.id + "' cannot be empty");
|
|
123
130
|
return;
|
|
124
131
|
}
|
|
125
|
-
this.service
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
132
|
+
this.service
|
|
133
|
+
.load(id)
|
|
134
|
+
.then(function (data) {
|
|
135
|
+
res.status(200).json(data).end();
|
|
136
|
+
})
|
|
137
|
+
.catch(function (err) {
|
|
138
|
+
return http_1.handleError(err, res, _this.log);
|
|
139
|
+
});
|
|
129
140
|
};
|
|
130
141
|
return SavedController;
|
|
131
|
-
}()
|
|
142
|
+
})();
|
|
132
143
|
exports.SavedController = SavedController;
|
|
133
144
|
var FollowController = (function () {
|
|
134
145
|
function FollowController(log, service, target, id) {
|
|
135
146
|
this.log = log;
|
|
136
147
|
this.service = service;
|
|
137
148
|
this.target = target;
|
|
138
|
-
this.id =
|
|
149
|
+
this.id = id && id.length > 0 ? id : 'id';
|
|
139
150
|
this.follow = this.follow.bind(this);
|
|
140
151
|
this.unfollow = this.unfollow.bind(this);
|
|
141
152
|
this.checkFollow = this.checkFollow.bind(this);
|
|
@@ -152,9 +163,14 @@ var FollowController = (function () {
|
|
|
152
163
|
res.status(400).end("'" + this.target + "' cannot be empty");
|
|
153
164
|
return;
|
|
154
165
|
}
|
|
155
|
-
this.service
|
|
156
|
-
|
|
157
|
-
|
|
166
|
+
this.service
|
|
167
|
+
.follow(id, target)
|
|
168
|
+
.then(function (count) {
|
|
169
|
+
return res.status(200).json(count).end();
|
|
170
|
+
})
|
|
171
|
+
.catch(function (err) {
|
|
172
|
+
return http_1.handleError(err, res, _this.log);
|
|
173
|
+
});
|
|
158
174
|
};
|
|
159
175
|
FollowController.prototype.unfollow = function (req, res) {
|
|
160
176
|
var _this = this;
|
|
@@ -168,9 +184,14 @@ var FollowController = (function () {
|
|
|
168
184
|
res.status(400).end("'" + this.target + "' cannot be empty");
|
|
169
185
|
return;
|
|
170
186
|
}
|
|
171
|
-
this.service
|
|
172
|
-
|
|
173
|
-
|
|
187
|
+
this.service
|
|
188
|
+
.unfollow(id, target)
|
|
189
|
+
.then(function (count) {
|
|
190
|
+
return res.status(200).json(count).end();
|
|
191
|
+
})
|
|
192
|
+
.catch(function (err) {
|
|
193
|
+
return http_1.handleError(err, res, _this.log);
|
|
194
|
+
});
|
|
174
195
|
};
|
|
175
196
|
FollowController.prototype.checkFollow = function (req, res) {
|
|
176
197
|
var _this = this;
|
|
@@ -184,12 +205,17 @@ var FollowController = (function () {
|
|
|
184
205
|
res.status(400).end("'" + this.target + "' cannot be empty");
|
|
185
206
|
return;
|
|
186
207
|
}
|
|
187
|
-
this.service
|
|
188
|
-
|
|
189
|
-
|
|
208
|
+
this.service
|
|
209
|
+
.checkFollow(id, target)
|
|
210
|
+
.then(function (count) {
|
|
211
|
+
return res.status(200).json(count).end();
|
|
212
|
+
})
|
|
213
|
+
.catch(function (err) {
|
|
214
|
+
return http_1.handleError(err, res, _this.log);
|
|
215
|
+
});
|
|
190
216
|
};
|
|
191
217
|
return FollowController;
|
|
192
|
-
}()
|
|
218
|
+
})();
|
|
193
219
|
exports.FollowController = FollowController;
|
|
194
220
|
var UserReactionController = (function () {
|
|
195
221
|
function UserReactionController(log, service, author, id, reaction) {
|
|
@@ -197,7 +223,7 @@ var UserReactionController = (function () {
|
|
|
197
223
|
this.service = service;
|
|
198
224
|
this.author = author;
|
|
199
225
|
this.reaction = reaction;
|
|
200
|
-
this.id =
|
|
226
|
+
this.id = id && id.length > 0 ? id : 'id';
|
|
201
227
|
this.react = this.react.bind(this);
|
|
202
228
|
this.unreact = this.unreact.bind(this);
|
|
203
229
|
this.checkReaction = this.checkReaction.bind(this);
|
|
@@ -219,9 +245,14 @@ var UserReactionController = (function () {
|
|
|
219
245
|
res.status(400).end("'" + this.reaction + "' cannot be empty");
|
|
220
246
|
return;
|
|
221
247
|
}
|
|
222
|
-
this.service
|
|
223
|
-
|
|
224
|
-
|
|
248
|
+
this.service
|
|
249
|
+
.react(id, author, reaction)
|
|
250
|
+
.then(function (count) {
|
|
251
|
+
return res.status(200).json(count).end();
|
|
252
|
+
})
|
|
253
|
+
.catch(function (err) {
|
|
254
|
+
return http_1.handleError(err, res, _this.log);
|
|
255
|
+
});
|
|
225
256
|
};
|
|
226
257
|
UserReactionController.prototype.unreact = function (req, res) {
|
|
227
258
|
var _this = this;
|
|
@@ -240,9 +271,14 @@ var UserReactionController = (function () {
|
|
|
240
271
|
res.status(400).end("'" + this.reaction + "' cannot be empty");
|
|
241
272
|
return;
|
|
242
273
|
}
|
|
243
|
-
this.service
|
|
244
|
-
|
|
245
|
-
|
|
274
|
+
this.service
|
|
275
|
+
.unreact(id, author, reaction)
|
|
276
|
+
.then(function (count) {
|
|
277
|
+
return res.status(200).json(count).end();
|
|
278
|
+
})
|
|
279
|
+
.catch(function (err) {
|
|
280
|
+
return http_1.handleError(err, res, _this.log);
|
|
281
|
+
});
|
|
246
282
|
};
|
|
247
283
|
UserReactionController.prototype.checkReaction = function (req, res) {
|
|
248
284
|
var _this = this;
|
|
@@ -256,12 +292,17 @@ var UserReactionController = (function () {
|
|
|
256
292
|
res.status(400).end("'" + this.author + "' cannot be empty");
|
|
257
293
|
return;
|
|
258
294
|
}
|
|
259
|
-
this.service
|
|
260
|
-
|
|
261
|
-
|
|
295
|
+
this.service
|
|
296
|
+
.checkReaction(id, author)
|
|
297
|
+
.then(function (count) {
|
|
298
|
+
return res.status(200).json(count).end();
|
|
299
|
+
})
|
|
300
|
+
.catch(function (err) {
|
|
301
|
+
return http_1.handleError(err, res, _this.log);
|
|
302
|
+
});
|
|
262
303
|
};
|
|
263
304
|
return UserReactionController;
|
|
264
|
-
}()
|
|
305
|
+
})();
|
|
265
306
|
exports.UserReactionController = UserReactionController;
|
|
266
307
|
exports.ReactController = UserReactionController;
|
|
267
308
|
exports.ReactionController = UserReactionController;
|