express-generator-typescript 2.5.20 → 2.5.21
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.
|
@@ -37,31 +37,27 @@ export interface IUser {
|
|
|
37
37
|
*/
|
|
38
38
|
function newUser(user?: Partial<IUser>): IUser {
|
|
39
39
|
const retVal = { ...DEFAULT_USER_VALS(), ...user };
|
|
40
|
-
return
|
|
40
|
+
return parseUser(retVal, errors => {
|
|
41
|
+
throw new Error('Setup new user failed ' + JSON.stringify(errors, null, 2));
|
|
42
|
+
});
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* Check is a user object. For the route validation.
|
|
45
47
|
*/
|
|
46
48
|
function testUser(arg: unknown, errCb?: TParseOnError): arg is IUser {
|
|
47
|
-
return !!
|
|
49
|
+
return !!parseUser(arg, errCb);
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
53
|
* Parse a user object.
|
|
52
54
|
*/
|
|
53
|
-
const parseUser =
|
|
55
|
+
const parseUser = parseObject<IUser>({
|
|
54
56
|
id: isRelationalKey,
|
|
55
57
|
name: isString,
|
|
56
58
|
email: isString,
|
|
57
59
|
created: transIsDate,
|
|
58
|
-
}
|
|
59
|
-
if (throwErr) {
|
|
60
|
-
throw new Error(JSON.stringify(errors, null, 2));
|
|
61
|
-
}
|
|
62
|
-
}),
|
|
63
|
-
parseWithErrs = parseUser(true),
|
|
64
|
-
parseWoErrs = parseUser();
|
|
60
|
+
});
|
|
65
61
|
|
|
66
62
|
|
|
67
63
|
/******************************************************************************
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"users":[{"id":
|
|
1
|
+
{"users":[{"id":838545008111,"name":"Bill","created":"2025-03-10T20:05:08.878Z","email":"sean.maxwell@gmail.com"},{"id":310043743347,"name":"John Smith","created":"2025-03-10T20:05:08.878Z","email":"john.smith@gmail.com"},{"id":989411758607,"name":"Gordan Freeman","created":"2025-03-10T20:05:08.878Z","email":"gordan.freeman@gmail.com"}]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.21",
|
|
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",
|