express-generator-typescript 2.0.9 → 2.0.11
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.
|
@@ -8,7 +8,7 @@ import User, { IUser } from '@models/user-model';
|
|
|
8
8
|
import { pErr } from '@shared/functions';
|
|
9
9
|
import { p as userPaths } from '@routes/user-router';
|
|
10
10
|
import loginAgent from '../support/login-agent';
|
|
11
|
-
import { ParamMissingError, UserNotFoundError } from '@shared/errors';
|
|
11
|
+
import { ParamMissingError, UserNotFoundError, ValidatorFnError } from '@shared/errors';
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
// **** Variables **** //
|
|
@@ -152,7 +152,7 @@ describe('user-router', () => {
|
|
|
152
152
|
.end((err: Error, res: Response) => {
|
|
153
153
|
pErr(err);
|
|
154
154
|
expect(res.status).toBe(BAD_REQUEST);
|
|
155
|
-
expect(res.body.error).toBe(
|
|
155
|
+
expect(res.body.error).toBe(ValidatorFnError.Msg + 'instanceOf');
|
|
156
156
|
done();
|
|
157
157
|
});
|
|
158
158
|
});
|
|
@@ -200,7 +200,7 @@ describe('user-router', () => {
|
|
|
200
200
|
.end((err: Error, res: Response) => {
|
|
201
201
|
pErr(err);
|
|
202
202
|
expect(res.status).toBe(BAD_REQUEST);
|
|
203
|
-
expect(res.body.error).toBe(
|
|
203
|
+
expect(res.body.error).toBe(ValidatorFnError.Msg + 'instanceOf');
|
|
204
204
|
done();
|
|
205
205
|
});
|
|
206
206
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Put other validator functions here too that may be passed to the validate() function
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { ParamInvalidError } from '@shared/errors';
|
|
5
|
+
import { ParamInvalidError, ValidatorFnError } from '@shared/errors';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
// **** Types **** //
|
|
@@ -34,7 +34,7 @@ function validate(...params: Array<TParam | TParamFull[]>): void {
|
|
|
34
34
|
if (typeof param[1] === 'function') {
|
|
35
35
|
const fn = param[1];
|
|
36
36
|
if (!fn(param[0])) {
|
|
37
|
-
throw new
|
|
37
|
+
throw new ValidatorFnError(fn.name);
|
|
38
38
|
}
|
|
39
39
|
// If type is a number, need to do isNaN, cause type NaN is a 'number'.
|
|
40
40
|
// This could be an issue if you do Number(undefined)
|
|
@@ -27,7 +27,17 @@ export class ParamInvalidError extends CustomError {
|
|
|
27
27
|
public static readonly HttpStatus = HttpStatusCodes.BAD_REQUEST;
|
|
28
28
|
|
|
29
29
|
constructor() {
|
|
30
|
-
super(
|
|
30
|
+
super(ParamInvalidError.Msg, ParamMissingError.HttpStatus);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class ValidatorFnError extends CustomError {
|
|
35
|
+
|
|
36
|
+
public static readonly Msg = 'Validator function failed. function name: ';
|
|
37
|
+
public static readonly HttpStatus = HttpStatusCodes.BAD_REQUEST;
|
|
38
|
+
|
|
39
|
+
constructor(fnName: string) {
|
|
40
|
+
super(ValidatorFnError.Msg + fnName, ParamMissingError.HttpStatus);
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "Generate new Express applications similar to express-generate which but sets it up to use TypeScript instead",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"express-generator-typescript": "node bin/cli.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/seanpmaxwell/express-generator-typescript#readme",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"edit-json-file": "^1.
|
|
49
|
+
"edit-json-file": "^1.7.0",
|
|
50
50
|
"ncp": "^2.0.0"
|
|
51
51
|
}
|
|
52
52
|
}
|