📈 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
a bit of code clean-up
Blue Mousea5cd4dab2d02
diff --git a/.env.example b/.env.exampleindex 3408116de..696194b90 100644--- a/.env.example+++ b/.env.example@@ -27,3 +27,6 @@ FROM_EMAIL='[email protected]'# Use SMTP_MOCK variable for development, leave empty when in productionSMTP_MOCK=true++# Is selfhosted (true -> will disable all restrictions related to tiers)+API_SELFHOSTED=falsediff --git a/src/analytics/analytics.service.ts b/src/analytics/analytics.service.tsindex fca1d11a1..0f0f3b2ba 100644--- a/src/analytics/analytics.service.ts+++ b/src/analytics/analytics.service.ts@@ -102,7 +102,7 @@ export class AnalyticsService {}}}-+// TODO: Remove unnecessary checks (because some of them are already checked in the DTO)async validate(logDTO: PageviewsDTO | EventsDTO, origin: string): Promise<string | null> {if (_isEmpty(logDTO)) throw new BadRequestException('The request cannot be empty')diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.tsindex 11b82dac5..c004dbae5 100644--- a/src/auth/auth.controller.ts+++ b/src/auth/auth.controller.ts@@ -50,7 +50,7 @@ export class AuthController {// await this.authService.checkCaptcha(userLoginDTO.recaptcha)const user = await this.authService.validateUser(userLoginDTO.email, userLoginDTO.password)- return await this.authService.login(user, request.res)+ return await this.authService.login(user)}@Post('/register')@@ -67,7 +67,7 @@ export class AuthController {const url = `${request.headers.origin}/verify/${actionToken.id}`await this.mailerService.sendEmail(userDTO.email, LetterTemplate.SignUp, { url })- return await this.authService.login(user, request.res)+ return await this.authService.login(user)} catch(e) {if (e.code === 'ER_DUP_ENTRY') {if (e.sqlMessage.includes(userDTO.email)) {diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.tsindex 0714101c2..4537a1d2f 100644--- a/src/auth/auth.service.ts+++ b/src/auth/auth.service.ts@@ -1,6 +1,5 @@import { Injectable, UnprocessableEntityException } from '@nestjs/common'import { sign } from 'jsonwebtoken'-import { Response } from 'express'import * as bcrypt from 'bcrypt'import { UserService } from '../user/user.service'@@ -32,18 +31,11 @@ export class AuthService {throw new UnprocessableEntityException('Email or password is incorrect')}- async login(user: User, res: Response): Promise<any> {- const options = {- httpOnly: true,- sameSite: false,- hostonly: true- }-+ async login(user: User): Promise<any> {const token = sign({ user_id: user.id }, process.env.JWT_SECRET, {expiresIn: JWT_LIFE_TIME,})- res.cookie('token', token, options)delete user.passwordreturn { access_token: token, user }}diff --git a/src/auth/jwt-payload.interface.ts b/src/auth/jwt-payload.interface.tsdeleted file mode 100644index 966898ee0..000000000--- a/src/auth/jwt-payload.interface.ts+++ /dev/null@@ -1,3 +0,0 @@-export interface JwtPayload {- user_id: string-}\ No newline at end of filediff --git a/src/auth/jwt.strategy.ts b/src/auth/jwt.strategy.tsdeleted file mode 100644index 3ef429f5c..000000000--- a/src/auth/jwt.strategy.ts+++ /dev/null@@ -1,19 +0,0 @@-import { ExtractJwt, Strategy } from 'passport-jwt'-import { PassportStrategy } from '@nestjs/passport'-import { Injectable } from '@nestjs/common'-import { JwtPayload } from './jwt-payload.interface'--@Injectable()-export class JwtStrategy extends PassportStrategy(Strategy) {- constructor() {- super({- jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),- ignoreExpiration: false,- secretOrKey: process.env.JWT_SECRET,- })- }-- async validate(payload: JwtPayload): Promise<JwtPayload> {- return { user_id: payload.user_id }- }-}\ No newline at end of filediff --git a/src/user/user.controller.ts b/src/user/user.controller.tsindex c5bc612f5..53976d615 100644--- a/src/user/user.controller.ts+++ b/src/user/user.controller.ts@@ -189,8 +189,8 @@ export class UserController {await this.userService.update(id, {...user, ...userDTO})return this.userService.findOneWhere({ id })} catch (e) {- if(e.code === 'ER_DUP_ENTRY'){- if(e.sqlMessage.includes(userDTO.email)) {+ if (e.code === 'ER_DUP_ENTRY'){+ if (e.sqlMessage.includes(userDTO.email)) {throw new BadRequestException('User with this email already exists')}}