express-ext 0.3.0 → 0.3.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/index.js +24 -0
- package/lib/resources.js +2 -2
- package/package.json +1 -1
- package/src/index.ts +51 -25
- package/src/metadata.ts +2 -1
- package/src/resources.ts +2 -2
package/lib/index.js
CHANGED
|
@@ -305,9 +305,33 @@ var UserReactionController = (function () {
|
|
|
305
305
|
exports.UserReactionController = UserReactionController;
|
|
306
306
|
exports.ReactController = UserReactionController;
|
|
307
307
|
exports.ReactionController = UserReactionController;
|
|
308
|
+
function addSeconds(date, number) {
|
|
309
|
+
var d = new Date(date);
|
|
310
|
+
d.setSeconds(d.getSeconds() + number);
|
|
311
|
+
return d;
|
|
312
|
+
}
|
|
313
|
+
exports.addSeconds = addSeconds;
|
|
314
|
+
function addMinutes(date, number) {
|
|
315
|
+
var d = new Date(date);
|
|
316
|
+
d.setMinutes(d.getMinutes() + number);
|
|
317
|
+
return d;
|
|
318
|
+
}
|
|
319
|
+
exports.addMinutes = addMinutes;
|
|
308
320
|
function addDays(d, n) {
|
|
309
321
|
var newDate = new Date(d);
|
|
310
322
|
newDate.setDate(newDate.getDate() + n);
|
|
311
323
|
return newDate;
|
|
312
324
|
}
|
|
313
325
|
exports.addDays = addDays;
|
|
326
|
+
function toMap(errors) {
|
|
327
|
+
var errorMap = {};
|
|
328
|
+
if (!errors) {
|
|
329
|
+
return errorMap;
|
|
330
|
+
}
|
|
331
|
+
for (var i = 0; i < errors.length; i++) {
|
|
332
|
+
errors[i].invalid = 'invalid';
|
|
333
|
+
errorMap[errors[i].field] = errors[i];
|
|
334
|
+
}
|
|
335
|
+
return errorMap;
|
|
336
|
+
}
|
|
337
|
+
exports.toMap = toMap;
|
package/lib/resources.js
CHANGED
|
@@ -6,7 +6,7 @@ var https = require('https');
|
|
|
6
6
|
var resources = (function () {
|
|
7
7
|
function resources() {}
|
|
8
8
|
resources.limits = [12, 24, 60, 100, 120, 180, 300, 600];
|
|
9
|
-
resources.
|
|
9
|
+
resources.pages = 'pages';
|
|
10
10
|
resources.page = 'page';
|
|
11
11
|
resources.limit = 'limit';
|
|
12
12
|
resources.defaultLimit = 12;
|
|
@@ -18,7 +18,7 @@ var resources = (function () {
|
|
|
18
18
|
exports.resources = resources;
|
|
19
19
|
function getView(req, view) {
|
|
20
20
|
var partial = req.query[resources.partial];
|
|
21
|
-
return partial == 'true' ? resources.
|
|
21
|
+
return partial == 'true' ? resources.pages + '/' + view : view;
|
|
22
22
|
}
|
|
23
23
|
exports.getView = getView;
|
|
24
24
|
var TypeChecker = (function () {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -7,37 +7,38 @@ import { LoadController } from './LoadController';
|
|
|
7
7
|
import { LoadSearchController } from './LoadSearchController';
|
|
8
8
|
import { LogController } from './LogController';
|
|
9
9
|
import { Controller, Service } from './LowCodeController';
|
|
10
|
+
import { ErrorMessage } from './metadata';
|
|
10
11
|
import { SearchController } from './SearchController';
|
|
11
12
|
|
|
12
13
|
export { HealthController as HealthHandler, LoadController as LoadHandler, LogController as LogHandler, LoadController as ViewHandler };
|
|
13
14
|
// export {LoadController as ViewController};
|
|
14
15
|
|
|
15
|
-
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
16
|
+
export {
|
|
17
|
+
GenericController as GenericHandler,
|
|
18
|
+
GenericSearchController as GenericSearchHandler,
|
|
19
|
+
Controller as Handler,
|
|
20
|
+
LoadSearchController as LoadSearchHandler,
|
|
21
|
+
Service as LowCodeService,
|
|
22
|
+
SearchController as SearchHandler
|
|
23
|
+
};
|
|
23
24
|
|
|
24
|
-
export * from './client';
|
|
25
|
-
export * from './edit';
|
|
26
|
-
export * from './GenericController';
|
|
27
|
-
export * from './GenericSearchController';
|
|
28
|
-
export * from './health';
|
|
29
|
-
export * from './HealthController';
|
|
30
|
-
export * from './http';
|
|
31
|
-
export * from './LoadController';
|
|
32
|
-
export * from './LoadSearchController';
|
|
33
|
-
export * from './log';
|
|
34
|
-
export * from './LogController';
|
|
35
|
-
export * from './LowCodeController';
|
|
36
|
-
export * from './metadata';
|
|
37
|
-
export * from './resources';
|
|
38
|
-
export * from './search';
|
|
39
|
-
export * from './SearchController';
|
|
40
|
-
export * from './view';
|
|
25
|
+
export * from './client';
|
|
26
|
+
export * from './edit';
|
|
27
|
+
export * from './GenericController';
|
|
28
|
+
export * from './GenericSearchController';
|
|
29
|
+
export * from './health';
|
|
30
|
+
export * from './HealthController';
|
|
31
|
+
export * from './http';
|
|
32
|
+
export * from './LoadController';
|
|
33
|
+
export * from './LoadSearchController';
|
|
34
|
+
export * from './log';
|
|
35
|
+
export * from './LogController';
|
|
36
|
+
export * from './LowCodeController';
|
|
37
|
+
export * from './metadata';
|
|
38
|
+
export * from './resources';
|
|
39
|
+
export * from './search';
|
|
40
|
+
export * from './SearchController';
|
|
41
|
+
export * from './view';
|
|
41
42
|
|
|
42
43
|
export interface AccessConfig {
|
|
43
44
|
origin?: string | string[];
|
|
@@ -290,8 +291,33 @@ export class UserReactionController {
|
|
|
290
291
|
}
|
|
291
292
|
export const ReactController = UserReactionController;
|
|
292
293
|
export const ReactionController = UserReactionController;
|
|
294
|
+
|
|
295
|
+
export function addSeconds(date: Date, number: number): Date {
|
|
296
|
+
const d = new Date(date);
|
|
297
|
+
d.setSeconds(d.getSeconds() + number);
|
|
298
|
+
return d;
|
|
299
|
+
}
|
|
300
|
+
export function addMinutes(date: Date, number: number): Date {
|
|
301
|
+
const d = new Date(date);
|
|
302
|
+
d.setMinutes(d.getMinutes() + number);
|
|
303
|
+
return d;
|
|
304
|
+
}
|
|
293
305
|
export function addDays(d: Date, n: number): Date {
|
|
294
306
|
const newDate = new Date(d);
|
|
295
307
|
newDate.setDate(newDate.getDate() + n);
|
|
296
308
|
return newDate;
|
|
297
309
|
}
|
|
310
|
+
export interface ErrorMap {
|
|
311
|
+
[key: string]: ErrorMessage
|
|
312
|
+
}
|
|
313
|
+
export function toMap(errors: ErrorMessage[]): ErrorMap {
|
|
314
|
+
const errorMap: ErrorMap = {}
|
|
315
|
+
if (!errors) {
|
|
316
|
+
return errorMap
|
|
317
|
+
}
|
|
318
|
+
for (let i = 0; i < errors.length; i++) {
|
|
319
|
+
errors[i].invalid = "invalid"
|
|
320
|
+
errorMap[errors[i].field] = errors[i]
|
|
321
|
+
}
|
|
322
|
+
return errorMap
|
|
323
|
+
}
|
package/src/metadata.ts
CHANGED
package/src/resources.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface StringMap {
|
|
|
10
10
|
// tslint:disable-next-line:class-name
|
|
11
11
|
export class resources {
|
|
12
12
|
static limits = [12, 24, 60, 100, 120, 180, 300, 600];
|
|
13
|
-
static
|
|
13
|
+
static pages = 'pages';
|
|
14
14
|
static page = 'page';
|
|
15
15
|
static limit = 'limit';
|
|
16
16
|
static defaultLimit = 12;
|
|
@@ -22,7 +22,7 @@ export class resources {
|
|
|
22
22
|
}
|
|
23
23
|
export function getView(req: Request, view: string): string {
|
|
24
24
|
const partial = req.query[resources.partial];
|
|
25
|
-
return partial == 'true' ? resources.
|
|
25
|
+
return partial == 'true' ? resources.pages + '/' + view : view;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface Validator<T> {
|