Skip to content

Commit 54afc42

Browse files
authored
Merge pull request #919 from nestjsx/feat/update-nestjs-version
feat: update nestjs version
2 parents 4ede828 + 91d771b commit 54afc42

File tree

5 files changed

+1277
-2793
lines changed

5 files changed

+1277
-2793
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
# Runs a single command using the runners shell
3434
- name: build docker db
35-
run: docker-compose up -d
35+
run: docker compose up -d
3636

3737
- name: install
3838
run: yarn install --ignore-scripts
@@ -41,10 +41,10 @@ jobs:
4141
run: yarn build
4242

4343
- name: check docker
44-
run: docker-compose up -d
44+
run: docker compose up -d
4545

4646
- name: docker logs
47-
run: docker-compose logs && docker-compose ps
47+
run: docker compose logs && docker compose ps
4848

4949
# Runs a set of commands using the runners shell
5050
- name: tests

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
"paginate"
1919
],
2020
"devDependencies": {
21-
"@nestjs/common": "^9.0.5",
22-
"@nestjs/core": "9.4.3",
23-
"@nestjs/testing": "^9.0.5",
24-
"@nestjs/typeorm": "^7.1.0",
21+
"@nestjs/common": "^11.0.0",
22+
"@nestjs/core": "^11.0.0",
23+
"@nestjs/testing": "^11.0.0",
24+
"@nestjs/typeorm": "^11.0.0",
2525
"@types/jest": "^27.0.0",
2626
"@types/node": "^20.9.0",
2727
"coveralls": "^3.0.5",
28-
"jest": "^26.6.3",
28+
"jest": "^29.7.0",
2929
"mysql": "^2.17.1",
3030
"prettier": "^3.1.0",
3131
"reflect-metadata": "^0.1.13",
32-
"rxjs": "^6.5.2",
33-
"ts-jest": "^26.4.4",
32+
"rxjs": "^7.8.2",
33+
"ts-jest": "^29.2.6",
3434
"ts-node": "^10.0.0",
3535
"typeorm": "0.3.17",
3636
"typescript": "^4.0.5"
@@ -46,7 +46,7 @@
4646
"prepublish": "npm run format && npm run build"
4747
},
4848
"peerDependencies": {
49-
"@nestjs/common": "^6.1.1 || ^5.6.2 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0",
49+
"@nestjs/common": "^6.1.1 || ^5.6.2 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
5050
"typeorm": "^0.3.0"
5151
},
5252
"jest": {

src/__tests__/mocks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from 'typeorm';
77

88
export class MockRepository extends Repository<any> {
9-
items = [];
9+
items: Entity[] = [];
1010
constructor(entityAmount: number) {
1111
super({} as EntityTarget<{}>, {} as EntityManager);
1212
for (let i = 0; i < entityAmount; i++) this.items.push(new Entity());
@@ -19,7 +19,7 @@ export class MockRepository extends Repository<any> {
1919
};
2020

2121
find = async (options?: FindManyOptions<any>): Promise<any[]> => {
22-
const startIndex = options.skip;
22+
const startIndex = options?.skip;
2323
const endIndex = startIndex + options.take;
2424

2525
const localItems = this.items.slice(startIndex, endIndex);

src/__tests__/paginate.repository.spec.ts

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ describe('Test paginate function', () => {
6262
route: 'http://example.com/something',
6363
});
6464

65-
expect(results.links.first).toBe('http://example.com/something?limit=4');
66-
expect(results.links.previous).toBe(
65+
expect(results.links?.first).toBe('http://example.com/something?limit=4');
66+
expect(results.links?.previous).toBe(
6767
'http://example.com/something?page=1&limit=4',
6868
);
69-
expect(results.links.next).toBe(
69+
expect(results.links?.next).toBe(
7070
'http://example.com/something?page=3&limit=4',
7171
);
72-
expect(results.links.last).toBe(
72+
expect(results.links?.last).toBe(
7373
'http://example.com/something?page=3&limit=4',
7474
);
7575
});
@@ -87,16 +87,16 @@ describe('Test paginate function', () => {
8787
},
8888
});
8989

90-
expect(results.links.first).toBe(
90+
expect(results.links?.first).toBe(
9191
'http://example.com/something?page-size=4',
9292
);
93-
expect(results.links.previous).toBe(
93+
expect(results.links?.previous).toBe(
9494
'http://example.com/something?current-page=1&page-size=4',
9595
);
96-
expect(results.links.next).toBe(
96+
expect(results.links?.next).toBe(
9797
'http://example.com/something?current-page=3&page-size=4',
9898
);
99-
expect(results.links.last).toBe(
99+
expect(results.links?.last).toBe(
100100
'http://example.com/something?current-page=3&page-size=4',
101101
);
102102
});
@@ -113,14 +113,14 @@ describe('Test paginate function', () => {
113113
},
114114
});
115115

116-
expect(results.links.first).toBe('http://example.com/something?limit=4');
117-
expect(results.links.previous).toBe(
116+
expect(results.links?.first).toBe('http://example.com/something?limit=4');
117+
expect(results.links?.previous).toBe(
118118
'http://example.com/something?current-page=1&limit=4',
119119
);
120-
expect(results.links.next).toBe(
120+
expect(results.links?.next).toBe(
121121
'http://example.com/something?current-page=3&limit=4',
122122
);
123-
expect(results.links.last).toBe(
123+
expect(results.links?.last).toBe(
124124
'http://example.com/something?current-page=3&limit=4',
125125
);
126126
});
@@ -137,16 +137,16 @@ describe('Test paginate function', () => {
137137
},
138138
});
139139

140-
expect(results.links.first).toBe(
140+
expect(results.links?.first).toBe(
141141
'http://example.com/something?page-size=4',
142142
);
143-
expect(results.links.previous).toBe(
143+
expect(results.links?.previous).toBe(
144144
'http://example.com/something?page=1&page-size=4',
145145
);
146-
expect(results.links.next).toBe(
146+
expect(results.links?.next).toBe(
147147
'http://example.com/something?page=3&page-size=4',
148148
);
149-
expect(results.links.last).toBe(
149+
expect(results.links?.last).toBe(
150150
'http://example.com/something?page=3&page-size=4',
151151
);
152152
});
@@ -160,12 +160,12 @@ describe('Test paginate function', () => {
160160
route: 'http://example.com/something',
161161
});
162162

163-
expect(results.links.first).toBe('http://example.com/something?limit=4');
164-
expect(results.links.previous).toBe('');
165-
expect(results.links.next).toBe(
163+
expect(results.links?.first).toBe('http://example.com/something?limit=4');
164+
expect(results.links?.previous).toBe('');
165+
expect(results.links?.next).toBe(
166166
'http://example.com/something?page=2&limit=4',
167167
);
168-
expect(results.links.last).toBe(
168+
expect(results.links?.last).toBe(
169169
'http://example.com/something?page=3&limit=4',
170170
);
171171
});
@@ -179,12 +179,12 @@ describe('Test paginate function', () => {
179179
route: 'http://example.com/something',
180180
});
181181

182-
expect(results.links.first).toBe('http://example.com/something?limit=4');
183-
expect(results.links.previous).toBe(
182+
expect(results.links?.first).toBe('http://example.com/something?limit=4');
183+
expect(results.links?.previous).toBe(
184184
'http://example.com/something?page=2&limit=4',
185185
);
186-
expect(results.links.next).toBe('');
187-
expect(results.links.last).toBe(
186+
expect(results.links?.next).toBe('');
187+
expect(results.links?.last).toBe(
188188
'http://example.com/something?page=3&limit=4',
189189
);
190190
});
@@ -198,12 +198,12 @@ describe('Test paginate function', () => {
198198
route: 'http://example.com/something',
199199
});
200200

201-
expect(results.links.first).toBe('http://example.com/something?limit=4');
202-
expect(results.links.previous).toBe('');
203-
expect(results.links.next).toBe(
201+
expect(results.links?.first).toBe('http://example.com/something?limit=4');
202+
expect(results.links?.previous).toBe('');
203+
expect(results.links?.next).toBe(
204204
'http://example.com/something?page=2&limit=4',
205205
);
206-
expect(results.links.last).toBe(
206+
expect(results.links?.last).toBe(
207207
'http://example.com/something?page=3&limit=4',
208208
);
209209
});
@@ -222,12 +222,12 @@ describe('Test paginate function', () => {
222222
});
223223

224224
expect(results.items.length).toBe(5);
225-
expect(results.links.first).toBe('http://example.com/something?limit=10');
226-
expect(results.links.previous).toBe(
225+
expect(results.links?.first).toBe('http://example.com/something?limit=10');
226+
expect(results.links?.previous).toBe(
227227
'http://example.com/something?page=1&limit=10',
228228
);
229-
expect(results.links.next).toBe('');
230-
expect(results.links.last).toBe(
229+
expect(results.links?.next).toBe('');
230+
expect(results.links?.last).toBe(
231231
'http://example.com/something?page=2&limit=10',
232232
);
233233
expect(consoleMock).toHaveBeenCalledWith(
@@ -249,12 +249,12 @@ describe('Test paginate function', () => {
249249
});
250250

251251
expect(results.items.length).toBe(4);
252-
expect(results.links.first).toBe('http://example.com/something?limit=4');
253-
expect(results.links.previous).toBe('');
254-
expect(results.links.next).toBe(
252+
expect(results.links?.first).toBe('http://example.com/something?limit=4');
253+
expect(results.links?.previous).toBe('');
254+
expect(results.links?.next).toBe(
255255
'http://example.com/something?page=2&limit=4',
256256
);
257-
expect(results.links.last).toBe(
257+
expect(results.links?.last).toBe(
258258
'http://example.com/something?page=3&limit=4',
259259
);
260260
expect(consoleMock).toHaveBeenCalledWith(
@@ -276,12 +276,12 @@ describe('Test paginate function', () => {
276276
});
277277

278278
expect(results.items.length).toBe(4);
279-
expect(results.links.first).toBe('http://example.com/something?limit=4');
280-
expect(results.links.previous).toBe('');
281-
expect(results.links.next).toBe(
279+
expect(results.links?.first).toBe('http://example.com/something?limit=4');
280+
expect(results.links?.previous).toBe('');
281+
expect(results.links?.next).toBe(
282282
'http://example.com/something?page=2&limit=4',
283283
);
284-
expect(results.links.last).toBe(
284+
expect(results.links?.last).toBe(
285285
'http://example.com/something?page=3&limit=4',
286286
);
287287
expect(consoleMock).toHaveBeenCalledWith(
@@ -303,12 +303,12 @@ describe('Test paginate function', () => {
303303
});
304304

305305
expect(results.items.length).toBe(4);
306-
expect(results.links.first).toBe('http://example.com/something?limit=4');
307-
expect(results.links.previous).toBe('');
308-
expect(results.links.next).toBe(
306+
expect(results.links?.first).toBe('http://example.com/something?limit=4');
307+
expect(results.links?.previous).toBe('');
308+
expect(results.links?.next).toBe(
309309
'http://example.com/something?page=2&limit=4',
310310
);
311-
expect(results.links.last).toBe(
311+
expect(results.links?.last).toBe(
312312
'http://example.com/something?page=3&limit=4',
313313
);
314314
expect(consoleMock).toHaveBeenCalledWith(
@@ -375,7 +375,7 @@ describe('Test paginate function', () => {
375375
route: '/test?test=test',
376376
});
377377

378-
expect(results.links.next).toBe('/test?test=test&page=2&limit=4');
378+
expect(results.links?.next).toBe('/test?test=test&page=2&limit=4');
379379
});
380380

381381
it('when page is 0, return empty pagination object', async () => {
@@ -388,10 +388,10 @@ describe('Test paginate function', () => {
388388
});
389389

390390
expect(results.items.length).toBe(0);
391-
expect(results.links.first).toBe('/test?test=test&limit=4');
392-
expect(results.links.previous).toBe('');
393-
expect(results.links.next).toBe('');
394-
expect(results.links.last).toBe('');
391+
expect(results.links?.first).toBe('/test?test=test&limit=4');
392+
expect(results.links?.previous).toBe('');
393+
expect(results.links?.next).toBe('');
394+
expect(results.links?.last).toBe('');
395395
});
396396

397397
it('Can use skip and take', async () => {
@@ -405,10 +405,10 @@ describe('Test paginate function', () => {
405405
});
406406

407407
expect(results.items.length).toBe(0);
408-
expect(results.links.first).toBe('/test?test=test&limit=4');
409-
expect(results.links.previous).toBe('');
410-
expect(results.links.next).toBe('');
411-
expect(results.links.last).toBe('');
408+
expect(results.links?.first).toBe('/test?test=test&limit=4');
409+
expect(results.links?.previous).toBe('');
410+
expect(results.links?.next).toBe('');
411+
expect(results.links?.last).toBe('');
412412
});
413413

414414
it('Can call paginate with no count queries', async () => {

0 commit comments

Comments
 (0)