Skip to content

Commit 7abcd1f

Browse files
committed
chore: update dependencies and improve import formatting across various modules for consistency and clarity
1 parent afb3dc2 commit 7abcd1f

35 files changed

+635
-630
lines changed

apps/backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"test:e2e": "bun test e2e/**/*.spec.ts"
2323
},
2424
"dependencies": {
25+
"@types/bun": "^1.2.10",
2526
"@aws-sdk/client-s3": "3.717.0",
2627
"@aws-sdk/s3-request-presigner": "3.717.0",
2728
"@encode42/nbs.js": "^5.0.2",

apps/backend/scripts/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import * as Bun from 'bun';
12
import { existsSync, mkdirSync, writeFileSync } from 'fs';
23
import { resolve } from 'path';
34

45
import { getLatestVersionSoundList } from '@nbw/sounds';
5-
import * as Bun from 'bun';
66

77
const writeSoundList = async () => {
88
function writeJSONFile(

apps/backend/src/auth/auth.controller.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { AuthService } from './auth.service';
66
import { MagicLinkEmailStrategy } from './strategies/magicLinkEmail.strategy';
77

88
const mockAuthService = {
9-
githubLogin: jest.fn(),
10-
googleLogin: jest.fn(),
11-
discordLogin: jest.fn(),
12-
verifyToken: jest.fn(),
9+
githubLogin : jest.fn(),
10+
googleLogin : jest.fn(),
11+
discordLogin : jest.fn(),
12+
verifyToken : jest.fn(),
1313
loginWithEmail: jest.fn(),
1414
};
1515

@@ -24,13 +24,13 @@ describe('AuthController', () => {
2424
beforeEach(async () => {
2525
const module: TestingModule = await Test.createTestingModule({
2626
controllers: [AuthController],
27-
providers: [
27+
providers : [
2828
{
29-
provide: AuthService,
29+
provide : AuthService,
3030
useValue: mockAuthService,
3131
},
3232
{
33-
provide: MagicLinkEmailStrategy,
33+
provide : MagicLinkEmailStrategy,
3434
useValue: mockMagicLinkEmailStrategy,
3535
},
3636
],

apps/backend/src/auth/auth.service.spec.ts

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { beforeEach, describe, expect, it, jest, mock, spyOn } from 'bun:test';
2+
13
import type { UserDocument } from '@nbw/database';
24
import { JwtService } from '@nestjs/jwt';
35
import { Test, TestingModule } from '@nestjs/testing';
4-
import { beforeEach, describe, expect, it, jest, mock, spyOn } from 'bun:test';
56
import type { Request, Response } from 'express';
67

78
import { UserService } from '@server/user/user.service';
@@ -10,9 +11,9 @@ import { AuthService } from './auth.service';
1011
import { Profile } from './types/profile';
1112

1213
const mockAxios = {
13-
get: jest.fn(),
14-
post: jest.fn(),
15-
put: jest.fn(),
14+
get : jest.fn(),
15+
post : jest.fn(),
16+
put : jest.fn(),
1617
delete: jest.fn(),
1718
create: jest.fn(),
1819
};
@@ -21,15 +22,15 @@ mock.module('axios', () => mockAxios);
2122

2223
const mockUserService = {
2324
generateUsername: jest.fn(),
24-
findByEmail: jest.fn(),
25-
findByID: jest.fn(),
26-
create: jest.fn(),
25+
findByEmail : jest.fn(),
26+
findByID : jest.fn(),
27+
create : jest.fn(),
2728
};
2829

2930
const mockJwtService = {
30-
decode: jest.fn(),
31+
decode : jest.fn(),
3132
signAsync: jest.fn(),
32-
verify: jest.fn(),
33+
verify : jest.fn(),
3334
};
3435

3536
describe('AuthService', () => {
@@ -42,47 +43,47 @@ describe('AuthService', () => {
4243
providers: [
4344
AuthService,
4445
{
45-
provide: UserService,
46+
provide : UserService,
4647
useValue: mockUserService,
4748
},
4849
{
49-
provide: JwtService,
50+
provide : JwtService,
5051
useValue: mockJwtService,
5152
},
5253
{
53-
provide: 'COOKIE_EXPIRES_IN',
54+
provide : 'COOKIE_EXPIRES_IN',
5455
useValue: '3600',
5556
},
5657
{
57-
provide: 'FRONTEND_URL',
58+
provide : 'FRONTEND_URL',
5859
useValue: 'http://frontend.test.com',
5960
},
6061
{
61-
provide: 'COOKIE_EXPIRES_IN',
62+
provide : 'COOKIE_EXPIRES_IN',
6263
useValue: '3600',
6364
},
6465
{
65-
provide: 'JWT_SECRET',
66+
provide : 'JWT_SECRET',
6667
useValue: 'test-jwt-secret',
6768
},
6869
{
69-
provide: 'JWT_EXPIRES_IN',
70+
provide : 'JWT_EXPIRES_IN',
7071
useValue: '1d',
7172
},
7273
{
73-
provide: 'JWT_REFRESH_SECRET',
74+
provide : 'JWT_REFRESH_SECRET',
7475
useValue: 'test-jwt-refresh-secret',
7576
},
7677
{
77-
provide: 'JWT_REFRESH_EXPIRES_IN',
78+
provide : 'JWT_REFRESH_EXPIRES_IN',
7879
useValue: '7d',
7980
},
8081
{
81-
provide: 'WHITELISTED_USERS',
82+
provide : 'WHITELISTED_USERS',
8283
useValue: 'tomast1337,bentroen,testuser',
8384
},
8485
{
85-
provide: 'APP_DOMAIN',
86+
provide : 'APP_DOMAIN',
8687
useValue: '.test.com',
8788
},
8889
],
@@ -103,7 +104,7 @@ describe('AuthService', () => {
103104

104105
const res = {
105106
status: jest.fn().mockReturnThis(),
106-
json: jest.fn(),
107+
json : jest.fn(),
107108
} as any;
108109

109110
await authService.verifyToken(req, res);
@@ -120,7 +121,7 @@ describe('AuthService', () => {
120121

121122
const res = {
122123
status: jest.fn().mockReturnThis(),
123-
json: jest.fn(),
124+
json : jest.fn(),
124125
} as any;
125126

126127
await authService.verifyToken(req, res);
@@ -136,7 +137,7 @@ describe('AuthService', () => {
136137

137138
const res = {
138139
status: jest.fn().mockReturnThis(),
139-
json: jest.fn(),
140+
json : jest.fn(),
140141
} as any;
141142

142143
mockJwtService.verify.mockReturnValueOnce({ id: 'test-id' });
@@ -155,7 +156,7 @@ describe('AuthService', () => {
155156

156157
const res = {
157158
status: jest.fn().mockReturnThis(),
158-
json: jest.fn(),
159+
json : jest.fn(),
159160
} as any;
160161

161162
const decodedToken = { id: 'test-id' };
@@ -206,17 +207,17 @@ describe('AuthService', () => {
206207
const tokens = await (authService as any).createJwtPayload(payload);
207208

208209
expect(tokens).toEqual({
209-
access_token: accessToken,
210+
access_token : accessToken,
210211
refresh_token: refreshToken,
211212
});
212213

213214
expect(jwtService.signAsync).toHaveBeenCalledWith(payload, {
214-
secret: 'test-jwt-secret',
215+
secret : 'test-jwt-secret',
215216
expiresIn: '1d',
216217
});
217218

218219
expect(jwtService.signAsync).toHaveBeenCalledWith(payload, {
219-
secret: 'test-jwt-refresh-secret',
220+
secret : 'test-jwt-refresh-secret',
220221
expiresIn: '7d',
221222
});
222223
});
@@ -225,18 +226,18 @@ describe('AuthService', () => {
225226
describe('GenTokenRedirect', () => {
226227
it('should set cookies and redirect to the frontend URL', async () => {
227228
const user_registered = {
228-
_id: 'user-id',
229-
229+
_id : 'user-id',
230+
email : '[email protected]',
230231
username: 'testuser',
231232
} as unknown as UserDocument;
232233

233234
const res = {
234-
cookie: jest.fn(),
235+
cookie : jest.fn(),
235236
redirect: jest.fn(),
236237
} as unknown as Response;
237238

238239
const tokens = {
239-
access_token: 'access-token',
240+
access_token : 'access-token',
240241
refresh_token: 'refresh-token',
241242
};
242243

@@ -245,8 +246,8 @@ describe('AuthService', () => {
245246
await (authService as any).GenTokenRedirect(user_registered, res);
246247

247248
expect((authService as any).createJwtPayload).toHaveBeenCalledWith({
248-
id: 'user-id',
249-
249+
id : 'user-id',
250+
email : '[email protected]',
250251
username: 'testuser',
251252
});
252253

@@ -271,8 +272,8 @@ describe('AuthService', () => {
271272
describe('verifyAndGetUser', () => {
272273
it('should create a new user if the user is not registered', async () => {
273274
const user: Profile = {
274-
username: 'testuser',
275-
275+
username : 'testuser',
276+
email : '[email protected]',
276277
profileImage: 'http://example.com/photo.jpg',
277278
};
278279

@@ -285,7 +286,7 @@ describe('AuthService', () => {
285286

286287
expect(userService.create).toHaveBeenCalledWith(
287288
expect.objectContaining({
288-
289+
email : '[email protected]',
289290
profileImage: 'http://example.com/photo.jpg',
290291
}),
291292
);
@@ -295,13 +296,13 @@ describe('AuthService', () => {
295296

296297
it('should return the registered user if the user is already registered', async () => {
297298
const user: Profile = {
298-
username: 'testuser',
299-
299+
username : 'testuser',
300+
email : '[email protected]',
300301
profileImage: 'http://example.com/photo.jpg',
301302
};
302303

303304
const registeredUser = {
304-
id: 'registered-user-id',
305+
id : 'registered-user-id',
305306
profileImage: 'http://example.com/photo.jpg',
306307
};
307308

@@ -315,15 +316,15 @@ describe('AuthService', () => {
315316

316317
it('should update the profile image if it has changed', async () => {
317318
const user: Profile = {
318-
username: 'testuser',
319-
319+
username : 'testuser',
320+
email : '[email protected]',
320321
profileImage: 'http://example.com/new-photo.jpg',
321322
};
322323

323324
const registeredUser = {
324-
id: 'registered-user-id',
325+
id : 'registered-user-id',
325326
profileImage: 'http://example.com/old-photo.jpg',
326-
save: jest.fn(),
327+
save : jest.fn(),
327328
};
328329

329330
mockUserService.findByEmail.mockResolvedValue(registeredUser);

apps/backend/src/auth/strategies/JWT.strategy.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('JwtStrategy', () => {
1313
providers: [
1414
JwtStrategy,
1515
{
16-
provide: ConfigService,
16+
provide : ConfigService,
1717
useValue: {
1818
getOrThrow: jest.fn().mockReturnValue('test-secret'),
1919
},

0 commit comments

Comments
 (0)