📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fixed linting issues
Blue Mouseea99d508b634
diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.tsindex f913d7385..1af890d5b 100644--- a/src/auth/auth.controller.ts+++ b/src/auth/auth.controller.ts@@ -14,6 +14,7 @@ import {Get,Param,UnauthorizedException,+ BadRequestException,Headers,} from '@nestjs/common'import {@@ -28,6 +29,7 @@ import * as _pick from 'lodash/pick'import { checkRateLimit } from 'src/common/utils'import { UserType } from 'src/user/entities/user.entity'import { UserService } from 'src/user/user.service'+import { isDevelopment } from 'src/common/constants'import { AuthService } from './auth.service'import { Public, CurrentUserId, CurrentUser, Roles } from './decorators'import {@@ -49,7 +51,6 @@ import {SSOUnlinkDto,} from './dtos'import { SSOProviders } from './dtos/sso-generate.dto'-import { isDevelopment } from 'src/common/constants'import { JwtAccessTokenGuard, JwtRefreshTokenGuard, RolesGuard } from './guards'const LOCAL_OAUTH_RATE_LIMIT = 2000@@ -431,7 +432,12 @@ export class AuthController {@Body() body: SSOGenerateDto,@Ip() ip: string,): Promise<any> {- await checkRateLimit(ip, 'sso-generate', isDevelopment ? LOCAL_OAUTH_RATE_LIMIT : PRODUCTION_OAUTH_RATE_LIMIT, 1800)+ await checkRateLimit(+ ip,+ 'sso-generate',+ isDevelopment ? LOCAL_OAUTH_RATE_LIMIT : PRODUCTION_OAUTH_RATE_LIMIT,+ 1800,+ )const { provider } = body@@ -442,6 +448,8 @@ export class AuthController {if (provider === SSOProviders.GITHUB) {return this.authService.generateGithubURL()}++ throw new BadRequestException('Unknown SSO provider supplied')}@ApiOperation({ summary: 'Process authentication token (or code)' })@@ -451,7 +459,12 @@ export class AuthController {@Body() body: ProcessSSOCodeDto,@Ip() ip: string,): Promise<any> {- await checkRateLimit(ip, 'sso-process', isDevelopment ? LOCAL_OAUTH_RATE_LIMIT : PRODUCTION_OAUTH_RATE_LIMIT, 1800)+ await checkRateLimit(+ ip,+ 'sso-process',+ isDevelopment ? LOCAL_OAUTH_RATE_LIMIT : PRODUCTION_OAUTH_RATE_LIMIT,+ 1800,+ )const { token, hash } = body@@ -467,7 +480,12 @@ export class AuthController {@Headers() headers: unknown,@Ip() ip: string,): Promise<any> {- await checkRateLimit(ip, 'sso-hash', isDevelopment ? LOCAL_OAUTH_RATE_LIMIT : PRODUCTION_OAUTH_RATE_LIMIT, 1800)+ await checkRateLimit(+ ip,+ 'sso-hash',+ isDevelopment ? LOCAL_OAUTH_RATE_LIMIT : PRODUCTION_OAUTH_RATE_LIMIT,+ 1800,+ )const { hash, provider } = body@@ -486,7 +504,12 @@ export class AuthController {@CurrentUserId() userId: string,@Ip() ip: string,): Promise<void> {- await checkRateLimit(ip, 'sso-link', isDevelopment ? LOCAL_OAUTH_RATE_LIMIT : PRODUCTION_OAUTH_RATE_LIMIT, 1800)+ await checkRateLimit(+ ip,+ 'sso-link',+ isDevelopment ? LOCAL_OAUTH_RATE_LIMIT : PRODUCTION_OAUTH_RATE_LIMIT,+ 1800,+ )const { hash, provider } = bodydiff --git a/src/auth/auth.service.ts b/src/auth/auth.service.tsindex 6f8cd65c2..0a4919db0 100644--- a/src/auth/auth.service.ts+++ b/src/auth/auth.service.ts@@ -1,7 +1,6 @@import {Injectable,InternalServerErrorException,- UnauthorizedException,BadRequestException,ConflictException,} from '@nestjs/common'@@ -50,19 +49,22 @@ import { UserGithubDTO } from '../user/dto/user-github.dto'const REDIS_SSO_SESSION_TIMEOUT = 60 * 5 // 5 minutesconst getSSORedisKey = (uuid: string) => `${REDIS_SSO_UUID}:${uuid}`const generateSSOState = (provider: SSOProviders) => `${provider}:${uuidv4()}`-const getSSOSessionProvider = (state: string): SSOProviders => _split(state, ':')[0] as SSOProviders+const getSSOSessionProvider = (state: string): SSOProviders =>+ _split(state, ':')[0] as SSOProvidersconst OAUTH_REDIRECT_URL = isDevelopment? 'http://localhost:3000/socialised': `${PRODUCTION_ORIGIN}/socialised`-const GITHUB_OAUTH2_CLIENT_ID = process.env.GITHUB_OAUTH2_CLIENT_ID-const GITHUB_OAUTH2_CLIENT_SECRET = process.env.GITHUB_OAUTH2_CLIENT_SECRET+const { GITHUB_OAUTH2_CLIENT_ID } = process.env+const { GITHUB_OAUTH2_CLIENT_SECRET } = process.env@Injectable()export class AuthService {oauth2Client: Auth.OAuth2Client+githubOAuthClientID: string+githubOAuthClientSecret: stringconstructor(@@ -509,10 +511,7 @@ export class AuthService {const user = await this.userService.create(query)- const jwtTokens = await this.generateJwtTokens(- user.id,- true,- )+ const jwtTokens = await this.generateJwtTokens(user.id, true)return {...jwtTokens,@@ -560,13 +559,18 @@ export class AuthService {return payload}- async authenticateSSO(ssoHash: string, headers: unknown, ip: string, provider: SSOProviders) {+ async authenticateSSO(+ ssoHash: string,+ headers: unknown,+ ip: string,+ provider: SSOProviders,+ ) {if (provider === SSOProviders.GOOGLE) {- return await this.authenticateGoogle(ssoHash, headers, ip)+ return this.authenticateGoogle(ssoHash, headers, ip)}if (provider === SSOProviders.GITHUB) {- return await this.authenticateGithub(ssoHash, headers, ip)+ return this.authenticateGithub(ssoHash, headers, ip)}throw new BadRequestException('Unknown SSO provider supplied')@@ -617,11 +621,11 @@ export class AuthService {const provider = getSSOSessionProvider(ssoHash)if (provider === SSOProviders.GOOGLE) {- return await this.processGoogleToken(token, ssoHash)+ return this.processGoogleToken(token, ssoHash)}if (provider === SSOProviders.GITHUB) {- return await this.processGithubCode(token, ssoHash)+ return this.processGithubCode(token, ssoHash)}throw new BadRequestException('Unknown SSO provider supplied')@@ -652,13 +656,17 @@ export class AuthService {)}- async linkSSOAccount(userId: string, ssoHash: string, provider: SSOProviders) {+ async linkSSOAccount(+ userId: string,+ ssoHash: string,+ provider: SSOProviders,+ ) {if (provider === SSOProviders.GOOGLE) {- return await this.linkGoogleAccount(userId, ssoHash)+ return this.linkGoogleAccount(userId, ssoHash)}if (provider === SSOProviders.GITHUB) {- return await this.linkGithubAccount(userId, ssoHash)+ return this.linkGithubAccount(userId, ssoHash)}throw new BadRequestException('Unknown SSO provider supplied')@@ -696,11 +704,11 @@ export class AuthService {async unlinkSSOAccount(userId: string, provider: SSOProviders) {if (provider === SSOProviders.GOOGLE) {- return await this.unlinkGoogleAccount(userId)+ return this.unlinkGoogleAccount(userId)}if (provider === SSOProviders.GITHUB) {- return await this.unlinkGithubAccount(userId)+ return this.unlinkGithubAccount(userId)}throw new BadRequestException('Unknown SSO provider supplied')@@ -806,7 +814,7 @@ export class AuthService {throw new BadRequestException('No email address found')}- email = _find(emails, (e) => e.primary).email+ email = _find(emails, e => e.primary).email} catch (reason) {console.error(`[ERROR][AuthService -> processGithubCode -> axios.get (emails)]: ${reason}`,@@ -848,10 +856,7 @@ export class AuthService {const user = await this.userService.create(query)- const jwtTokens = await this.generateJwtTokens(- user.id,- true,- )+ const jwtTokens = await this.generateJwtTokens(user.id, true)return {...jwtTokens,diff --git a/src/user/user.service.ts b/src/user/user.service.tsindex 2a6c778c2..d78631ff1 100644--- a/src/user/user.service.ts+++ b/src/user/user.service.ts@@ -22,7 +22,9 @@ export class UserService {private readonly refreshTokenRepository: Repository<RefreshToken>,) {}- async create(userDTO: UserProfileDTO | User | UserGoogleDTO | UserGithubDTO): Promise<User> {+ async create(+ userDTO: UserProfileDTO | User | UserGoogleDTO | UserGithubDTO,+ ): Promise<User> {return this.usersRepository.save(userDTO)}