express-generator-typescript 2.7.16 → 2.7.18

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.
@@ -33,7 +33,7 @@ const schema: Schema<IUser> = {
33
33
  export interface IUser extends Entity {
34
34
  name: string;
35
35
  email: string;
36
- };
36
+ }
37
37
 
38
38
  /******************************************************************************
39
39
  Setup
@@ -1 +1,22 @@
1
- {"users":[{"id":279249255772,"name":"Bill","email":"sean.maxwell@gmail.com","created":"2026-01-28T05:15:24.564Z"},{"id":374980001180,"name":"John Smith","email":"john.smith@gmail.com","created":"2026-01-28T05:15:24.564Z"},{"id":551114509623,"name":"Gordan Freeman","email":"gordan.freeman@gmail.com","created":"2026-01-28T05:15:24.564Z"}]}
1
+ {
2
+ "users": [
3
+ {
4
+ "id": 73635186571,
5
+ "name": "Bill",
6
+ "email": "sean.maxwell@gmail.com",
7
+ "created": "2026-01-28T05:23:46.132Z"
8
+ },
9
+ {
10
+ "id": 438243754038,
11
+ "name": "John Smith",
12
+ "email": "john.smith@gmail.com",
13
+ "created": "2026-01-28T05:23:46.132Z"
14
+ },
15
+ {
16
+ "id": 948123879878,
17
+ "name": "Gordan Freeman",
18
+ "email": "gordan.freeman@gmail.com",
19
+ "created": "2026-01-28T05:23:46.132Z"
20
+ }
21
+ ]
22
+ }
@@ -5,7 +5,7 @@ import HttpStatusCodes from '@src/common/constants/HttpStatusCodes';
5
5
  import User from '@src/models/User.model';
6
6
  import UserService from '@src/services/UserService';
7
7
 
8
- import { IReq, IRes } from './common/express-types';
8
+ import { Req, Res } from './common/express-types';
9
9
  import parseReq from './common/parseReq';
10
10
 
11
11
  /******************************************************************************
@@ -27,7 +27,7 @@ const reqValidators = {
27
27
  *
28
28
  * @route GET /api/users/all
29
29
  */
30
- async function getAll(_: IReq, res: IRes) {
30
+ async function getAll(_: Req, res: Res) {
31
31
  const users = await UserService.getAll();
32
32
  res.status(HttpStatusCodes.OK).json({ users });
33
33
  }
@@ -37,7 +37,7 @@ async function getAll(_: IReq, res: IRes) {
37
37
  *
38
38
  * @route POST /api/users/add
39
39
  */
40
- async function add(req: IReq, res: IRes) {
40
+ async function add(req: Req, res: Res) {
41
41
  const { user } = reqValidators.add(req.body);
42
42
  await UserService.addOne(user);
43
43
  res.status(HttpStatusCodes.CREATED).end();
@@ -48,7 +48,7 @@ async function add(req: IReq, res: IRes) {
48
48
  *
49
49
  * @route PUT /api/users/update
50
50
  */
51
- async function update(req: IReq, res: IRes) {
51
+ async function update(req: Req, res: Res) {
52
52
  const { user } = reqValidators.update(req.body);
53
53
  await UserService.updateOne(user);
54
54
  res.status(HttpStatusCodes.OK).end();
@@ -59,7 +59,7 @@ async function update(req: IReq, res: IRes) {
59
59
  *
60
60
  * @route DELETE /api/users/delete/:id
61
61
  */
62
- async function delete_(req: IReq, res: IRes) {
62
+ async function delete_(req: Req, res: Res) {
63
63
  const { id } = reqValidators.delete(req.params);
64
64
  await UserService.delete(id);
65
65
  res.status(HttpStatusCodes.OK).end();
@@ -5,5 +5,7 @@ import { PlainObject } from 'jet-validators';
5
5
  Types
6
6
  ******************************************************************************/
7
7
 
8
- export type IReq = Request<PlainObject, void, PlainObject, PlainObject>;
9
- export type IRes = Response<unknown, PlainObject>;
8
+ type UrlParams = Record<string, string>;
9
+
10
+ export type Req = Request<UrlParams, void, PlainObject>;
11
+ export type Res = Response;
@@ -5,7 +5,7 @@ import { Response } from 'supertest';
5
5
  ******************************************************************************/
6
6
 
7
7
  // Use generics to add properties to 'body'
8
- export interface IRes<T = object> extends Omit<Response, 'body'> {
8
+ export interface TestRes<T = object> extends Omit<Response, 'body'> {
9
9
  body: T & { error?: string | ErrorObject };
10
10
  }
11
11
 
@@ -5,7 +5,7 @@ import User, { IUser } from '@src/models/User.model';
5
5
  import UserRepo from '@src/repos/UserRepo';
6
6
 
7
7
  import { agent } from './support/agent';
8
- import { IRes } from './common/supertest-types';
8
+ import { TestRes } from './common/supertest-types';
9
9
  import { parseValidationError } from './common/error-utils';
10
10
  import UserService from '@src/services/UserService';
11
11
  import { compareUserArrays } from './common/comparators';
@@ -42,7 +42,7 @@ describe('UserRouter', () => {
42
42
  'should return a JSON object with all the users and a status code of ' +
43
43
  `"${OK}" if the request was successful.`,
44
44
  async () => {
45
- const res: IRes<{ users: IUser[] }> = await agent.get(Paths.Users.Get);
45
+ const res: TestRes<{ users: IUser[] }> = await agent.get(Paths.Users.Get);
46
46
  expect(res.status).toBe(OK);
47
47
  expect(compareUserArrays(res.body.users, DUMMY_USERS)).toBeTruthy();
48
48
  },
@@ -64,7 +64,7 @@ describe('UserRouter', () => {
64
64
  'should return a JSON object with an error message of and a status ' +
65
65
  `code of "${BAD_REQUEST}" if the user param was missing.`,
66
66
  async () => {
67
- const res: IRes = await agent
67
+ const res: TestRes = await agent
68
68
  .post(Paths.Users.Add)
69
69
  .send({ user: null });
70
70
  expect(res.status).toBe(BAD_REQUEST);
@@ -89,7 +89,7 @@ describe('UserRouter', () => {
89
89
  async () => {
90
90
  const user = User.new();
91
91
  user.id = '5' as unknown as number;
92
- const res: IRes = await agent.put(Paths.Users.Update).send({ user });
92
+ const res: TestRes = await agent.put(Paths.Users.Update).send({ user });
93
93
  expect(res.status).toBe(BAD_REQUEST);
94
94
  const errorObj = parseValidationError(res.body.error);
95
95
  expect(errorObj.message).toBe(ValidationError.MESSAGE);
@@ -103,7 +103,7 @@ describe('UserRouter', () => {
103
103
  `"${NOT_FOUND}" if the id was not found.`,
104
104
  async () => {
105
105
  const user = User.new({ id: 4, name: 'a', email: 'a@a.com' }),
106
- res: IRes = await agent.put(Paths.Users.Update).send({ user });
106
+ res: TestRes = await agent.put(Paths.Users.Update).send({ user });
107
107
  expect(res.status).toBe(NOT_FOUND);
108
108
  expect(res.body.error).toBe(UserService.Errors.USER_NOT_FOUND);
109
109
  },
@@ -122,7 +122,7 @@ describe('UserRouter', () => {
122
122
  `"${UserService.Errors.USER_NOT_FOUND}" and a status code of ` +
123
123
  '"${NOT_FOUND}" if the id was not found.',
124
124
  async () => {
125
- const res: IRes = await agent.delete(Paths.Users.Delete(-1));
125
+ const res: TestRes = await agent.delete(Paths.Users.Delete(-1));
126
126
  expect(res.status).toBe(NOT_FOUND);
127
127
  expect(res.body.error).toBe(UserService.Errors.USER_NOT_FOUND);
128
128
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-generator-typescript",
3
- "version": "2.7.16",
3
+ "version": "2.7.18",
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",