express-generator-typescript 2.5.19 → 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.
package/README.md
CHANGED
|
@@ -15,4 +15,6 @@ This project complies with Typescript best practices listed <a href="https://git
|
|
|
15
15
|
<br/>
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
## Documenation
|
|
19
|
+
|
|
18
20
|
Please refer to the official <a href="https://github.com/seanpmaxwell/express-generator-typescript">github repo</a> for the most up-to-date documentation.
|
|
@@ -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 parseUser(
|
|
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 !!parseUser(
|
|
49
|
+
return !!parseUser(arg, errCb);
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
53
|
* Parse a user object.
|
|
52
54
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, errors => {
|
|
60
|
-
if (throwErr) {
|
|
61
|
-
throw new Error(JSON.stringify(errors));
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
55
|
+
const parseUser = parseObject<IUser>({
|
|
56
|
+
id: isRelationalKey,
|
|
57
|
+
name: isString,
|
|
58
|
+
email: isString,
|
|
59
|
+
created: transIsDate,
|
|
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"}]}
|
|
@@ -4,6 +4,15 @@ import { parseObject, TSchema } from 'jet-validators/utils';
|
|
|
4
4
|
import { ValidationError } from '@src/common/route-errors';
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Types
|
|
9
|
+
******************************************************************************/
|
|
10
|
+
|
|
11
|
+
type TRecord = Record<string, unknown>;
|
|
12
|
+
export type IReq = Request<TRecord, void, TRecord, TRecord>;
|
|
13
|
+
export type IRes = Response<unknown, TRecord>;
|
|
14
|
+
|
|
15
|
+
|
|
7
16
|
/******************************************************************************
|
|
8
17
|
Functions
|
|
9
18
|
******************************************************************************/
|
|
@@ -17,12 +26,3 @@ export function parseReq<U extends TSchema>(schema: U) {
|
|
|
17
26
|
throw new ValidationError(errors);
|
|
18
27
|
});
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/******************************************************************************
|
|
23
|
-
Types
|
|
24
|
-
******************************************************************************/
|
|
25
|
-
|
|
26
|
-
type TRecord = Record<string, unknown>;
|
|
27
|
-
export type IReq = Request<TRecord, void, TRecord, TRecord>;
|
|
28
|
-
export type IRes = Response<unknown, TRecord>;
|
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",
|