express-generator-typescript 2.5.10 → 2.5.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.
@@ -4,6 +4,10 @@ import logger from 'jet-logger';
4
4
  import { argv } from 'process';
5
5
 
6
6
 
7
+ /******************************************************************************
8
+ Run
9
+ ******************************************************************************/
10
+
7
11
  // Init Jasmine
8
12
  const jasmine = new Jasmine();
9
13
  jasmine.exitOnCompletion = false;
@@ -18,7 +18,9 @@ import { convertValidDates } from 'spec/support';
18
18
  import { TApiCb, TRes } from 'spec/types/misc';
19
19
 
20
20
 
21
- // **** Setup **** //
21
+ /******************************************************************************
22
+ Setup
23
+ ******************************************************************************/
22
24
 
23
25
  // Dummy users for GET req
24
26
  const getDummyUsers = () => [
@@ -40,7 +42,9 @@ const wrapCb = (cb: TApiCb) => (err: Error, res: TRes) => {
40
42
  };
41
43
 
42
44
 
43
- // **** Run Tests **** //
45
+ /******************************************************************************
46
+ Tests
47
+ ******************************************************************************/
44
48
 
45
49
  describe('UserRouter', () => {
46
50
 
@@ -4,6 +4,10 @@ import { isEnumVal } from 'jet-validators';
4
4
  import { NodeEnvs } from './constants';
5
5
 
6
6
 
7
+ /******************************************************************************
8
+ Export default
9
+ ******************************************************************************/
10
+
7
11
  export default jetEnv({
8
12
  NodeEnv: isEnumVal(NodeEnvs),
9
13
  Port: num,
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable max-len */
2
- /**
3
- * This file was copied from here: https://gist.github.com/scokmen/f813c904ef79022e84ab2409574d1b45
4
- */
2
+
5
3
 
6
4
  /**
7
5
  * Hypertext Transfer Protocol (HTTP) response status codes.
8
6
  * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
7
+ *
8
+ * This file was copied from here: https://gist.github.com/scokmen/f813c904ef79022e84ab2409574d1b45
9
9
  */
10
10
  enum HttpStatusCodes {
11
11
 
@@ -383,4 +383,9 @@ enum HttpStatusCodes {
383
383
  NETWORK_AUTHENTICATION_REQUIRED = 511
384
384
  }
385
385
 
386
+
387
+ /******************************************************************************
388
+ Export default
389
+ ******************************************************************************/
390
+
386
391
  export default HttpStatusCodes;
@@ -1,3 +1,8 @@
1
+
2
+ /******************************************************************************
3
+ Enums
4
+ ******************************************************************************/
5
+
1
6
  export enum NodeEnvs {
2
7
  Dev = 'development',
3
8
  Test = 'test',
@@ -1,6 +1,10 @@
1
1
  import HttpStatusCodes from '@src/common/HttpStatusCodes';
2
2
 
3
3
 
4
+ /******************************************************************************
5
+ Types
6
+ ******************************************************************************/
7
+
4
8
  export interface IValidationErrFormat {
5
9
  error: string;
6
10
  parameter: string;
@@ -9,6 +13,10 @@ export interface IValidationErrFormat {
9
13
  }
10
14
 
11
15
 
16
+ /******************************************************************************
17
+ Classes
18
+ ******************************************************************************/
19
+
12
20
  /**
13
21
  * Error with status code and message.
14
22
  */
@@ -4,7 +4,9 @@ import Env from '@src/common/Env';
4
4
  import server from './server';
5
5
 
6
6
 
7
- // **** Run **** //
7
+ /******************************************************************************
8
+ Run
9
+ ******************************************************************************/
8
10
 
9
11
  const SERVER_START_MSG = ('Express server started on port: ' +
10
12
  Env.Port.toString());
@@ -4,6 +4,10 @@ import schema from '@src/util/schema';
4
4
  import { isRelationalKey } from '@src/util/validators';
5
5
 
6
6
 
7
+ /******************************************************************************
8
+ Types
9
+ ******************************************************************************/
10
+
7
11
  export interface IUser {
8
12
  id: number;
9
13
  name: string;
@@ -11,6 +15,11 @@ export interface IUser {
11
15
  created: Date;
12
16
  }
13
17
 
18
+
19
+ /******************************************************************************
20
+ Setup
21
+ ******************************************************************************/
22
+
14
23
  const User = schema<IUser>({
15
24
  id: isRelationalKey,
16
25
  name: isString,
@@ -19,6 +28,8 @@ const User = schema<IUser>({
19
28
  });
20
29
 
21
30
 
22
- // **** Export default **** //
31
+ /******************************************************************************
32
+ Export default
33
+ ******************************************************************************/
23
34
 
24
35
  export default User;
@@ -1,4 +1,8 @@
1
- // **** Variables **** //
1
+ // @ts-nocheck
2
+
3
+ /******************************************************************************
4
+ Variables
5
+ ******************************************************************************/
2
6
 
3
7
  const DateFormatter = new Intl.DateTimeFormat('en-US', {
4
8
  year: 'numeric',
@@ -9,11 +13,18 @@ const DateFormatter = new Intl.DateTimeFormat('en-US', {
9
13
  const formatDate = (date) => DateFormatter.format(new Date(date));
10
14
 
11
15
 
12
- // **** Run **** //
16
+ /******************************************************************************
17
+ Run
18
+ ******************************************************************************/
13
19
 
14
20
  // Start
15
21
  displayUsers();
16
22
 
23
+
24
+ /******************************************************************************
25
+ Functions
26
+ ******************************************************************************/
27
+
17
28
  /**
18
29
  * Call api
19
30
  */
@@ -3,19 +3,25 @@ import jsonfile from 'jsonfile';
3
3
  import { IUser } from '@src/models/User';
4
4
 
5
5
 
6
- // **** Variables **** //
6
+ /******************************************************************************
7
+ Variables
8
+ ******************************************************************************/
7
9
 
8
10
  const DB_FILE_NAME = 'database.json';
9
11
 
10
12
 
11
- // **** Types **** //
13
+ /******************************************************************************
14
+ Types
15
+ ******************************************************************************/
12
16
 
13
17
  interface IDb {
14
18
  users: IUser[];
15
19
  }
16
20
 
17
21
 
18
- // **** Functions **** //
22
+ /******************************************************************************
23
+ Functions
24
+ ******************************************************************************/
19
25
 
20
26
  /**
21
27
  * Fetch the json from the file.
@@ -32,7 +38,9 @@ function saveDb(db: IDb): Promise<void> {
32
38
  }
33
39
 
34
40
 
35
- // **** Export default **** //
41
+ /******************************************************************************
42
+ Export default
43
+ ******************************************************************************/
36
44
 
37
45
  export default {
38
46
  openDb,
@@ -3,7 +3,9 @@ import { getRandomInt } from '@src/util/misc';
3
3
  import orm from './MockOrm';
4
4
 
5
5
 
6
- // **** Functions **** //
6
+ /******************************************************************************
7
+ Functions
8
+ ******************************************************************************/
7
9
 
8
10
  /**
9
11
  * Get one user.
@@ -81,7 +83,9 @@ async function delete_(id: number): Promise<void> {
81
83
  }
82
84
 
83
85
 
84
- // **** Export default **** //
86
+ /******************************************************************************
87
+ Export default
88
+ ******************************************************************************/
85
89
 
86
90
  export default {
87
91
  getOne,
@@ -9,7 +9,9 @@ import User from '@src/models/User';
9
9
  import { parseReq, IReq, IRes } from './common';
10
10
 
11
11
 
12
- // **** Variables **** //
12
+ /******************************************************************************
13
+ Variables
14
+ ******************************************************************************/
13
15
 
14
16
  const Validators = {
15
17
  add: parseReq({ user: User.test }),
@@ -18,7 +20,9 @@ const Validators = {
18
20
  } as const;
19
21
 
20
22
 
21
- // **** Functions **** //
23
+ /******************************************************************************
24
+ Functions
25
+ ******************************************************************************/
22
26
 
23
27
  /**
24
28
  * Get all users.
@@ -56,7 +60,9 @@ async function delete_(req: IReq, res: IRes) {
56
60
  }
57
61
 
58
62
 
59
- // **** Export default **** //
63
+ /******************************************************************************
64
+ Export default
65
+ ******************************************************************************/
60
66
 
61
67
  export default {
62
68
  getAll,
@@ -5,14 +5,18 @@ import { parseObject, TSchema } from 'jet-validators/utils';
5
5
  import { ValidationErr } from '@src/common/route-errors';
6
6
 
7
7
 
8
- // **** Types **** //
8
+ /******************************************************************************
9
+ Types
10
+ ******************************************************************************/
9
11
 
10
12
  type TRecord = Record<string, unknown>;
11
13
  export type IReq = Request<TRecord, void, TRecord, TRecord>;
12
14
  export type IRes = Response<unknown, TRecord>;
13
15
 
14
16
 
15
- // **** Functions **** //
17
+ /******************************************************************************
18
+ Functions
19
+ ******************************************************************************/
16
20
 
17
21
  /**
18
22
  * Parse a Request object property and throw a Validation error if it fails.
@@ -4,7 +4,9 @@ import Paths from './common/Paths';
4
4
  import UserRoutes from './UserRoutes';
5
5
 
6
6
 
7
- // **** Variables **** //
7
+ /******************************************************************************
8
+ Variables
9
+ ******************************************************************************/
8
10
 
9
11
  const apiRouter = Router();
10
12
 
@@ -24,6 +26,8 @@ userRouter.delete(Paths.Users.Delete, UserRoutes.delete);
24
26
  apiRouter.use(Paths.Users.Base, userRouter);
25
27
 
26
28
 
27
- // **** Export default **** //
29
+ /******************************************************************************
30
+ Export default
31
+ ******************************************************************************/
28
32
 
29
33
  export default apiRouter;
@@ -15,12 +15,14 @@ import { RouteError } from '@src/common/route-errors';
15
15
  import { NodeEnvs } from '@src/common/constants';
16
16
 
17
17
 
18
- // **** Variables **** //
18
+ /******************************************************************************
19
+ Variables
20
+ ******************************************************************************/
19
21
 
20
22
  const app = express();
21
23
 
22
24
 
23
- // **** Setup **** //
25
+ // **** Setup
24
26
 
25
27
  // Basic middleware
26
28
  app.use(express.json());
@@ -53,7 +55,7 @@ app.use((err: Error, _: Request, res: Response, next: NextFunction) => {
53
55
  });
54
56
 
55
57
 
56
- // **** Front-End Content **** //
58
+ // **** Front-End Content
57
59
 
58
60
  // Set views directory (html)
59
61
  const viewsDir = path.join(__dirname, 'views');
@@ -74,6 +76,8 @@ app.get('/users', (_: Request, res: Response) => {
74
76
  });
75
77
 
76
78
 
77
- // **** Export default **** //
79
+ /******************************************************************************
80
+ Export default
81
+ ******************************************************************************/
78
82
 
79
83
  export default app;
@@ -5,12 +5,16 @@ import UserRepo from '@src/repos/UserRepo';
5
5
  import { IUser } from '@src/models/User';
6
6
 
7
7
 
8
- // **** Variables **** //
8
+ /******************************************************************************
9
+ Variables
10
+ ******************************************************************************/
9
11
 
10
12
  export const USER_NOT_FOUND_ERR = 'User not found';
11
13
 
12
14
 
13
- // **** Functions **** //
15
+ /******************************************************************************
16
+ Functions
17
+ ******************************************************************************/
14
18
 
15
19
  /**
16
20
  * Get all users.
@@ -57,7 +61,9 @@ async function _delete(id: number): Promise<void> {
57
61
  }
58
62
 
59
63
 
60
- // **** Export default **** //
64
+ /******************************************************************************
65
+ Export default
66
+ ******************************************************************************/
61
67
 
62
68
  export default {
63
69
  getAll,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-generator-typescript",
3
- "version": "2.5.10",
3
+ "version": "2.5.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",