Skip to content

Commit 71d3080

Browse files
committed
chore: lint
1 parent f4d4cce commit 71d3080

File tree

126 files changed

+982
-1007
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+982
-1007
lines changed

apps/backend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"start:dev": "bun --watch run src/main.ts",
1515
"start:debug": "bun --watch run src/main.ts",
1616
"start:prod": "node dist/main",
17-
"lint": "eslint \"src/**/*.ts\" --fix",
17+
"lint": "eslint \"src/**/*.ts\" --fix --config ../../eslint.config.ts",
1818
"test": "bun test src/**/*.spec.ts",
1919
"test:watch": "bun test src/**/*.spec.ts --watch",
2020
"test:cov": "bun test src/**/*.spec.ts --coverage",
@@ -67,6 +67,7 @@
6767
"@nestjs/cli": "^10.4.9",
6868
"@nestjs/schematics": "^10.2.3",
6969
"@nestjs/testing": "^10.4.15",
70+
"@stylistic/eslint-plugin": "^5.4.0",
7071
"@types/bcryptjs": "^2.4.6",
7172
"@types/bun": "^1.2.10",
7273
"@types/express": "^4.17.21",

apps/backend/scripts/build.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as Bun from 'bun';
21
import { existsSync, mkdirSync, writeFileSync } from 'fs';
32
import { resolve } from 'path';
43

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

77
const writeSoundList = async () => {
88
function writeJSONFile(
@@ -61,11 +61,11 @@ const build = async () => {
6161

6262
const result = await Bun.build({
6363
entrypoints: ['./src/main.ts'],
64-
outdir: './dist',
65-
target: 'bun',
66-
minify: false,
67-
sourcemap: 'linked',
68-
external: optionalRequirePackages.filter((pkg) => {
64+
outdir : './dist',
65+
target : 'bun',
66+
minify : false,
67+
sourcemap : 'linked',
68+
external : optionalRequirePackages.filter((pkg) => {
6969
try {
7070
require(pkg);
7171
return false;

apps/backend/src/app.module.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,42 @@ import { UserModule } from './user/user.module';
1919
@Module({
2020
imports: [
2121
ConfigModule.forRoot({
22-
isGlobal: true,
22+
isGlobal : true,
2323
envFilePath: ['.env.development', '.env.production'],
2424
validate,
2525
}),
2626
//DatabaseModule,
2727
MongooseModule.forRootAsync({
28-
imports: [ConfigModule],
29-
inject: [ConfigService],
28+
imports : [ConfigModule],
29+
inject : [ConfigService],
3030
useFactory: (
3131
configService: ConfigService,
3232
): MongooseModuleFactoryOptions => {
3333
const url = configService.getOrThrow<string>('MONGO_URL');
3434
Logger.debug(`Connecting to ${url}`);
3535

3636
return {
37-
uri: url,
37+
uri : url,
3838
retryAttempts: 10,
39-
retryDelay: 3000,
39+
retryDelay : 3000,
4040
};
4141
},
4242
}),
4343
// Mailing
4444
MailerModule.forRootAsync({
45-
imports: [ConfigModule],
45+
imports : [ConfigModule],
4646
useFactory: (configService: ConfigService) => {
4747
const transport = configService.getOrThrow<string>('MAIL_TRANSPORT');
4848
const from = configService.getOrThrow<string>('MAIL_FROM');
4949
AppModule.logger.debug(`MAIL_TRANSPORT: ${transport}`);
5050
AppModule.logger.debug(`MAIL_FROM: ${from}`);
5151
return {
5252
transport: transport,
53-
defaults: {
53+
defaults : {
5454
from: from,
5555
},
5656
template: {
57-
dir: __dirname + '/mailing/templates',
57+
dir : __dirname + '/mailing/templates',
5858
adapter: new HandlebarsAdapter(),
5959
options: {
6060
strict: true,
@@ -67,7 +67,7 @@ import { UserModule } from './user/user.module';
6767
// Throttler
6868
ThrottlerModule.forRoot([
6969
{
70-
ttl: 60,
70+
ttl : 60,
7171
limit: 256, // 256 requests per minute
7272
},
7373
]),
@@ -81,10 +81,10 @@ import { UserModule } from './user/user.module';
8181
MailingModule,
8282
],
8383
controllers: [],
84-
providers: [
84+
providers : [
8585
ParseTokenPipe,
8686
{
87-
provide: APP_GUARD,
87+
provide : APP_GUARD,
8888
useClass: ThrottlerGuard,
8989
},
9090
],

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class AuthController {
3232
@Throttle({
3333
default: {
3434
// one every 1 hour
35-
ttl: 60 * 60 * 1000,
35+
ttl : 60 * 60 * 1000,
3636
limit: 1,
3737
},
3838
})
@@ -44,11 +44,11 @@ export class AuthController {
4444
content: {
4545
'application/json': {
4646
schema: {
47-
type: 'object',
47+
type : 'object',
4848
properties: {
4949
destination: {
50-
type: 'string',
51-
example: '[email protected]',
50+
type : 'string',
51+
example : '[email protected]',
5252
description: 'Email address to send the magic link to',
5353
},
5454
},
@@ -58,7 +58,7 @@ export class AuthController {
5858
},
5959
},
6060
})
61-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
61+
6262
public async magicLinkLogin(@Req() req: Request, @Res() res: Response) {
6363
throw new HttpException('Not implemented', HttpStatus.NOT_IMPLEMENTED);
6464
// TODO: uncomment this line to enable magic link login

apps/backend/src/auth/auth.module.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import { MagicLinkEmailStrategy } from './strategies/magicLinkEmail.strategy';
1717
export class AuthModule {
1818
static forRootAsync(): DynamicModule {
1919
return {
20-
module: AuthModule,
20+
module : AuthModule,
2121
imports: [
2222
UserModule,
2323
ConfigModule.forRoot(),
2424
MailingModule,
2525
JwtModule.registerAsync({
26-
inject: [ConfigService],
27-
imports: [ConfigModule],
26+
inject : [ConfigService],
27+
imports : [ConfigModule],
2828
useFactory: async (config: ConfigService) => {
2929
const JWT_SECRET = config.get('JWT_SECRET');
3030
const JWT_EXPIRES_IN = config.get('JWT_EXPIRES_IN');
@@ -39,14 +39,14 @@ export class AuthModule {
3939
}
4040

4141
return {
42-
secret: JWT_SECRET,
42+
secret : JWT_SECRET,
4343
signOptions: { expiresIn: JWT_EXPIRES_IN || '60s' },
4444
};
4545
},
4646
}),
4747
],
4848
controllers: [AuthController],
49-
providers: [
49+
providers : [
5050
AuthService,
5151
ConfigService,
5252
GoogleStrategy,
@@ -55,56 +55,56 @@ export class AuthModule {
5555
MagicLinkEmailStrategy,
5656
JwtStrategy,
5757
{
58-
inject: [ConfigService],
59-
provide: 'COOKIE_EXPIRES_IN',
58+
inject : [ConfigService],
59+
provide : 'COOKIE_EXPIRES_IN',
6060
useFactory: (configService: ConfigService) =>
6161
configService.getOrThrow<string>('COOKIE_EXPIRES_IN'),
6262
},
6363
{
64-
inject: [ConfigService],
65-
provide: 'SERVER_URL',
64+
inject : [ConfigService],
65+
provide : 'SERVER_URL',
6666
useFactory: (configService: ConfigService) =>
6767
configService.getOrThrow<string>('SERVER_URL'),
6868
},
6969
{
70-
inject: [ConfigService],
71-
provide: 'FRONTEND_URL',
70+
inject : [ConfigService],
71+
provide : 'FRONTEND_URL',
7272
useFactory: (configService: ConfigService) =>
7373
configService.getOrThrow<string>('FRONTEND_URL'),
7474
},
7575
{
76-
inject: [ConfigService],
77-
provide: 'JWT_SECRET',
76+
inject : [ConfigService],
77+
provide : 'JWT_SECRET',
7878
useFactory: (configService: ConfigService) =>
7979
configService.getOrThrow<string>('JWT_SECRET'),
8080
},
8181
{
82-
inject: [ConfigService],
83-
provide: 'JWT_EXPIRES_IN',
82+
inject : [ConfigService],
83+
provide : 'JWT_EXPIRES_IN',
8484
useFactory: (configService: ConfigService) =>
8585
configService.getOrThrow<string>('JWT_EXPIRES_IN'),
8686
},
8787
{
88-
inject: [ConfigService],
89-
provide: 'JWT_REFRESH_SECRET',
88+
inject : [ConfigService],
89+
provide : 'JWT_REFRESH_SECRET',
9090
useFactory: (configService: ConfigService) =>
9191
configService.getOrThrow<string>('JWT_REFRESH_SECRET'),
9292
},
9393
{
94-
inject: [ConfigService],
95-
provide: 'JWT_REFRESH_EXPIRES_IN',
94+
inject : [ConfigService],
95+
provide : 'JWT_REFRESH_EXPIRES_IN',
9696
useFactory: (configService: ConfigService) =>
9797
configService.getOrThrow<string>('JWT_REFRESH_EXPIRES_IN'),
9898
},
9999
{
100-
inject: [ConfigService],
101-
provide: 'MAGIC_LINK_SECRET',
100+
inject : [ConfigService],
101+
provide : 'MAGIC_LINK_SECRET',
102102
useFactory: (configService: ConfigService) =>
103103
configService.getOrThrow<string>('MAGIC_LINK_SECRET'),
104104
},
105105
{
106-
inject: [ConfigService],
107-
provide: 'APP_DOMAIN',
106+
inject : [ConfigService],
107+
provide : 'APP_DOMAIN',
108108
useFactory: (configService: ConfigService) =>
109109
configService.get<string>('APP_DOMAIN'),
110110
},

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type { Request, Response } from 'express';
77

88
import { UserService } from '@server/user/user.service';
99

10+
11+
1012
import { DiscordUser } from './types/discordProfile';
1113
import { GithubAccessToken, GithubEmailList } from './types/githubProfile';
1214
import { GoogleProfile } from './types/googleProfile';
@@ -76,8 +78,8 @@ export class AuthService {
7678

7779
const profile = {
7880
// Generate username from display name
79-
username: email.split('@')[0],
80-
email: email,
81+
username : email.split('@')[0],
82+
email : email,
8183
profileImage: user.photos[0].value,
8284
};
8385

@@ -93,8 +95,8 @@ export class AuthService {
9395
const newUsername = await this.userService.generateUsername(baseUsername);
9496

9597
const newUser = new CreateUser({
96-
username: newUsername,
97-
email: email,
98+
username : newUsername,
99+
email : email,
98100
profileImage: profileImage,
99101
});
100102

@@ -134,8 +136,8 @@ export class AuthService {
134136
const email = response.data.filter((email) => email.primary)[0].email;
135137

136138
const user_registered = await this.verifyAndGetUser({
137-
username: profile.username,
138-
email: email,
139+
username : profile.username,
140+
email : email,
139141
profileImage: profile.photos[0].value,
140142
});
141143

@@ -148,8 +150,8 @@ export class AuthService {
148150

149151
const profile = {
150152
// Generate username from display name
151-
username: user.username,
152-
email: user.email,
153+
username : user.username,
154+
email : user.email,
153155
profileImage: profilePictureUrl,
154156
};
155157

@@ -172,17 +174,17 @@ export class AuthService {
172174
public async createJwtPayload(payload: TokenPayload): Promise<Tokens> {
173175
const [accessToken, refreshToken] = await Promise.all([
174176
this.jwtService.signAsync(payload, {
175-
secret: this.JWT_SECRET,
177+
secret : this.JWT_SECRET,
176178
expiresIn: this.JWT_EXPIRES_IN,
177179
}),
178180
this.jwtService.signAsync(payload, {
179-
secret: this.JWT_REFRESH_SECRET,
181+
secret : this.JWT_REFRESH_SECRET,
180182
expiresIn: this.JWT_REFRESH_EXPIRES_IN,
181183
}),
182184
]);
183185

184186
return {
185-
access_token: accessToken,
187+
access_token : accessToken,
186188
refresh_token: refreshToken,
187189
};
188190
}
@@ -192,8 +194,8 @@ export class AuthService {
192194
res: Response<any, Record<string, any>>,
193195
): Promise<void> {
194196
const token = await this.createJwtPayload({
195-
id: user_registered._id.toString(),
196-
email: user_registered.email,
197+
id : user_registered._id.toString(),
198+
email : user_registered.email,
197199
username: user_registered.username,
198200
});
199201

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt-refresh') {
1111
const JWT_SECRET = config.getOrThrow('JWT_SECRET');
1212

1313
super({
14-
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
15-
secretOrKey: JWT_SECRET,
14+
jwtFromRequest : ExtractJwt.fromAuthHeaderAsBearerToken(),
15+
secretOrKey : JWT_SECRET,
1616
passReqToCallback: true,
1717
});
1818
}

0 commit comments

Comments
 (0)