express-generator-typescript 2.8.0 → 2.9.0
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 +6 -7
- package/bin/cli.js +91 -32
- package/lib/express-generator-typescript.js +125 -153
- package/lib/{project-files → template}/.prettierignore +2 -4
- package/lib/template/README.md +50 -0
- package/lib/template/bs-config.js +8 -0
- package/lib/{project-files → template}/config/.env.development +4 -6
- package/lib/{project-files → template}/config/.env.production +4 -5
- package/lib/{project-files → template}/config/.env.test +4 -5
- package/lib/{project-files → template}/eslint.config.ts +4 -0
- package/lib/template/gitignore +10 -0
- package/lib/template/package.json +68 -0
- package/lib/{project-files → template}/src/common/constants/HttpStatusCodes.ts +7 -8
- package/lib/template/src/common/constants/Paths.ts +22 -0
- package/lib/template/src/common/constants/env.ts +28 -0
- package/lib/template/src/common/types/utility-types.ts +5 -0
- package/lib/template/src/common/utils/date-utils.ts +29 -0
- package/lib/template/src/common/utils/route-errors.ts +37 -0
- package/lib/template/src/main.ts +24 -0
- package/lib/template/src/models/User.model.ts +95 -0
- package/lib/template/src/models/common/types.ts +10 -0
- package/lib/template/src/public/scripts/http.js +25 -0
- package/lib/template/src/public/scripts/lib/bootstrap.bundle.min.js +4229 -0
- package/lib/template/src/public/scripts/renderUsers.js +90 -0
- package/lib/template/src/public/scripts/users.js +142 -0
- package/lib/template/src/public/stylesheets/lib/bootstrap.min.css +11798 -0
- package/lib/template/src/repos/MockOrm.ts +71 -0
- package/lib/{project-files → template}/src/repos/UserRepo.ts +21 -35
- package/lib/template/src/repos/common/database.json +28 -0
- package/lib/{project-files → template}/src/routes/UserRoutes.ts +15 -18
- package/lib/template/src/routes/apiRouter.ts +28 -0
- package/lib/template/src/routes/common/express-types.ts +9 -0
- package/lib/template/src/routes/common/parseReq.ts +23 -0
- package/lib/{project-files → template}/src/server.ts +23 -18
- package/lib/template/src/services/UserService.ts +66 -0
- package/lib/{project-files → template}/src/views/users.html +13 -6
- package/lib/{project-files → template}/tests/common/comparators.ts +6 -6
- package/lib/template/tests/common/supertest-types.ts +11 -0
- package/lib/template/tests/frontend.test.ts +33 -0
- package/lib/template/tests/support/agent.ts +23 -0
- package/lib/template/tests/users.test.ts +205 -0
- package/lib/{project-files → template}/tsconfig.json +1 -3
- package/lib/{project-files → template}/tsconfig.prod.json +3 -9
- package/lib/{project-files → template}/vitest.config.mts +2 -0
- package/package.json +69 -52
- package/lib/cli.js +0 -33
- package/lib/project-files/README.md +0 -39
- package/lib/project-files/gitignore +0 -4
- package/lib/project-files/package.json +0 -70
- package/lib/project-files/src/common/constants/Paths.ts +0 -15
- package/lib/project-files/src/common/constants/env.ts +0 -28
- package/lib/project-files/src/common/types/structure-utils.ts +0 -2
- package/lib/project-files/src/common/utils/number-utils.ts +0 -10
- package/lib/project-files/src/common/utils/route-errors.ts +0 -35
- package/lib/project-files/src/common/utils/validators.ts +0 -14
- package/lib/project-files/src/main.ts +0 -24
- package/lib/project-files/src/models/User.model.ts +0 -72
- package/lib/project-files/src/models/common/types.ts +0 -4
- package/lib/project-files/src/public/stylesheets/lib/bootstrap.min.css +0 -6
- package/lib/project-files/src/repos/MockOrm.ts +0 -63
- package/lib/project-files/src/repos/common/database.json +0 -1
- package/lib/project-files/src/repos/common/database.test.json +0 -1
- package/lib/project-files/src/routes/apiRouter.ts +0 -28
- package/lib/project-files/src/routes/common/express-types.ts +0 -8
- package/lib/project-files/src/routes/common/parseReq.ts +0 -19
- package/lib/project-files/src/services/UserService.ts +0 -64
- package/lib/project-files/tests/common/error-utils.ts +0 -25
- package/lib/project-files/tests/common/supertest-types.ts +0 -15
- package/lib/project-files/tests/support/agent.ts +0 -23
- package/lib/project-files/tests/users.test.ts +0 -131
- /package/lib/{project-files → template}/.prettierrc.json +0 -0
- /package/lib/{project-files → template}/src/public/stylesheets/users.css +0 -0
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import logger from 'jet-logger';
|
|
2
|
-
|
|
3
|
-
import EnvVars from './common/constants/env';
|
|
4
|
-
import server from './server';
|
|
5
|
-
|
|
6
|
-
/******************************************************************************
|
|
7
|
-
Constants
|
|
8
|
-
******************************************************************************/
|
|
9
|
-
|
|
10
|
-
const SERVER_START_MESSAGE =
|
|
11
|
-
'Express server started on port: ' + EnvVars.Port.toString();
|
|
12
|
-
|
|
13
|
-
/******************************************************************************
|
|
14
|
-
Run
|
|
15
|
-
******************************************************************************/
|
|
16
|
-
|
|
17
|
-
// Start the server
|
|
18
|
-
server.listen(EnvVars.Port, (err) => {
|
|
19
|
-
if (!!err) {
|
|
20
|
-
logger.err(err.message);
|
|
21
|
-
} else {
|
|
22
|
-
logger.info(SERVER_START_MESSAGE);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { isNonEmptyString, isString, isUnsignedInteger } from 'jet-validators';
|
|
2
|
-
import { parseObject, Schema, testObject } from 'jet-validators/utils';
|
|
3
|
-
|
|
4
|
-
import { transformIsDate } from '@src/common/utils/validators';
|
|
5
|
-
|
|
6
|
-
import { Entity } from './common/types';
|
|
7
|
-
|
|
8
|
-
/******************************************************************************
|
|
9
|
-
Constants
|
|
10
|
-
******************************************************************************/
|
|
11
|
-
|
|
12
|
-
const GetDefaults = (): IUser => ({
|
|
13
|
-
id: 0,
|
|
14
|
-
name: '',
|
|
15
|
-
email: '',
|
|
16
|
-
created: new Date(),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const schema: Schema<IUser> = {
|
|
20
|
-
id: isUnsignedInteger,
|
|
21
|
-
name: isString,
|
|
22
|
-
email: isString,
|
|
23
|
-
created: transformIsDate,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/******************************************************************************
|
|
27
|
-
Types
|
|
28
|
-
******************************************************************************/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @entity users
|
|
32
|
-
*/
|
|
33
|
-
export interface IUser extends Entity {
|
|
34
|
-
name: string;
|
|
35
|
-
email: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/******************************************************************************
|
|
39
|
-
Setup
|
|
40
|
-
******************************************************************************/
|
|
41
|
-
|
|
42
|
-
// Set the "parseUser" function
|
|
43
|
-
const parseUser = parseObject<IUser>(schema);
|
|
44
|
-
|
|
45
|
-
// For the APIs make sure the right fields are complete
|
|
46
|
-
const isCompleteUser = testObject<IUser>({
|
|
47
|
-
...schema,
|
|
48
|
-
name: isNonEmptyString,
|
|
49
|
-
email: isNonEmptyString,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
/******************************************************************************
|
|
53
|
-
Functions
|
|
54
|
-
******************************************************************************/
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* New user object.
|
|
58
|
-
*/
|
|
59
|
-
function new_(user?: Partial<IUser>): IUser {
|
|
60
|
-
return parseUser({ ...GetDefaults(), ...user }, (errors) => {
|
|
61
|
-
throw new Error('Setup new user failed ' + JSON.stringify(errors, null, 2));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/******************************************************************************
|
|
66
|
-
Export default
|
|
67
|
-
******************************************************************************/
|
|
68
|
-
|
|
69
|
-
export default {
|
|
70
|
-
new: new_,
|
|
71
|
-
isComplete: isCompleteUser,
|
|
72
|
-
} as const;
|