express-generator-typescript 2.7.0 → 2.7.1

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.
@@ -43,6 +43,13 @@ function saveDb(db: IDb): Promise<void> {
43
43
  return jsonfile.writeFile((__dirname + '/' + DB_FILE_NAME), db);
44
44
  }
45
45
 
46
+ /**
47
+ * Empty the database
48
+ */
49
+ function cleanDb(): Promise<void> {
50
+ return jsonfile.writeFile((__dirname + '/' + DB_FILE_NAME), {});
51
+ }
52
+
46
53
 
47
54
  /******************************************************************************
48
55
  Export default
@@ -51,4 +58,5 @@ function saveDb(db: IDb): Promise<void> {
51
58
  export default {
52
59
  openDb,
53
60
  saveDb,
61
+ cleanDb,
54
62
  } as const;
@@ -1 +1,22 @@
1
- {"users":[{"id":37508014430,"name":"Sean Maxwell","created":"2025-04-30T18:16:40.961Z","email":"sean.maxwell@gmail.com"},{"id":188309817441,"name":"John Smith","created":"2025-04-30T18:16:40.961Z","email":"john.smith@gmail.com"},{"id":787266485461,"name":"Gordan Freeman","created":"2025-04-30T18:16:40.961Z","email":"gordan.freeman@gmail.com"},{"id":448607986518,"name":"Sean Maxwell","created":"2025-04-30T18:16:40.990Z","email":"sean.maxwell@gmail.com"},{"id":517772227440,"name":"John Smith","created":"2025-04-30T18:16:40.990Z","email":"john.smith@gmail.com"},{"id":341201737995,"name":"Gordan Freeman","created":"2025-04-30T18:16:40.990Z","email":"gordan.freeman@gmail.com"},{"id":15893202169,"name":"a","created":"2025-04-30T18:16:40.991Z","email":"a@a.com"},{"id":929445117117,"name":"Sean Maxwell","created":"2025-04-30T18:16:41.008Z","email":"sean.maxwell@gmail.com"},{"id":414870034077,"name":"John Smith","created":"2025-04-30T18:16:41.008Z","email":"john.smith@gmail.com"},{"id":425170167908,"name":"Gordan Freeman","created":"2025-04-30T18:16:41.008Z","email":"gordan.freeman@gmail.com"},{"id":668144426266,"name":"Bill","created":"2025-04-30T18:16:41.029Z","email":"sean.maxwell@gmail.com"},{"id":346599891503,"name":"John Smith","created":"2025-04-30T18:16:41.029Z","email":"john.smith@gmail.com"},{"id":868427536392,"name":"Gordan Freeman","created":"2025-04-30T18:16:41.029Z","email":"gordan.freeman@gmail.com"},{"id":781342423953,"name":"Bill","created":"2025-04-30T18:16:41.038Z","email":"sean.maxwell@gmail.com"},{"id":259532967654,"name":"John Smith","created":"2025-04-30T18:16:41.038Z","email":"john.smith@gmail.com"},{"id":128343184794,"name":"Gordan Freeman","created":"2025-04-30T18:16:41.038Z","email":"gordan.freeman@gmail.com"},{"id":137492210417,"name":"Bill","created":"2025-04-30T18:16:41.045Z","email":"sean.maxwell@gmail.com"},{"id":393535542925,"name":"John Smith","created":"2025-04-30T18:16:41.045Z","email":"john.smith@gmail.com"},{"id":332379349789,"name":"Gordan Freeman","created":"2025-04-30T18:16:41.045Z","email":"gordan.freeman@gmail.com"},{"id":923502375831,"name":"John Smith","created":"2025-04-30T18:16:41.052Z","email":"john.smith@gmail.com"},{"id":119305864617,"name":"Gordan Freeman","created":"2025-04-30T18:16:41.052Z","email":"gordan.freeman@gmail.com"},{"id":269664001282,"name":"Bill","created":"2025-04-30T18:16:41.060Z","email":"sean.maxwell@gmail.com"},{"id":988915527591,"name":"John Smith","created":"2025-04-30T18:16:41.060Z","email":"john.smith@gmail.com"},{"id":851898715932,"name":"Gordan Freeman","created":"2025-04-30T18:16:41.060Z","email":"gordan.freeman@gmail.com"}]}
1
+ {
2
+ "users": [
3
+ {
4
+ "id": 752712205078,
5
+ "name": "Bill",
6
+ "created": "2025-04-30T18:42:44.406Z",
7
+ "email": "sean.maxwell@gmail.com"
8
+ },
9
+ {
10
+ "id": 874707860804,
11
+ "name": "John Smith",
12
+ "created": "2025-04-30T18:42:44.406Z",
13
+ "email": "john.smith@gmail.com"
14
+ },
15
+ {
16
+ "id": 299903074095,
17
+ "name": "Gordan Freeman",
18
+ "created": "2025-04-30T18:42:44.406Z",
19
+ "email": "gordan.freeman@gmail.com"
20
+ }
21
+ ]
22
+ }
@@ -1,5 +1,4 @@
1
1
  import { Response } from 'supertest';
2
- import UserRepo from '@src/repos/UserRepo';
3
2
 
4
3
 
5
4
  /******************************************************************************
@@ -15,19 +14,3 @@ interface IErrObj {
15
14
  message: string;
16
15
  [key: string]: unknown;
17
16
  }
18
-
19
-
20
- /******************************************************************************
21
- Functions
22
- ******************************************************************************/
23
-
24
- /**
25
- * Delete all records for unit testing.
26
- */
27
- export async function cleanDatabase(): Promise<void> {
28
- await Promise.all([
29
- UserRepo.deleteAllUsers(),
30
- ]);
31
- }
32
-
33
-
@@ -4,7 +4,7 @@ import supertest, { Test } from 'supertest';
4
4
  import TestAgent from 'supertest/lib/agent';
5
5
 
6
6
  import app from '@src/server';
7
- import UserRepo from '@src/repos/UserRepo';
7
+ import MockOrm from '@src/repos/MockOrm';
8
8
 
9
9
 
10
10
  /******************************************************************************
@@ -15,9 +15,7 @@ let agent: TestAgent<Test>;
15
15
 
16
16
  beforeAll(async () => {
17
17
  agent = supertest.agent(app);
18
- await Promise.all([
19
- UserRepo.deleteAllUsers(),
20
- ]);
18
+ await MockOrm.cleanDb();
21
19
  });
22
20
 
23
21
 
@@ -44,6 +44,7 @@ describe('UserRouter', () => {
44
44
 
45
45
  // Run before all tests
46
46
  beforeEach(async () => {
47
+ await UserRepo.deleteAllUsers();
47
48
  dbUsers = await UserRepo.insertMult(DB_USERS);
48
49
  });
49
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-generator-typescript",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
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",