📈 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
updated docker compose file and dto login
Yevhenii Kulisidib2be00e82e94
diff --git a/.env.example b/.env.exampleindex 385a9b8e3..9672851e4 100644--- a/.env.example+++ b/.env.example@@ -10,8 +10,8 @@ JWT_REFRESH_TOKEN_SECRET='jwt-refresh-token-secret'# DatabaseMYSQL_HOST=localhost-MYSQL_USER=host_user-MYSQL_ROOT_PASSWORD=password+MYSQL_USER=root+MYSQL_ROOT_PASSWORD=MYSQL_DATABASE=analyticsREDIS_HOST=localhostREDIS_PORT=6379@@ -20,7 +20,7 @@ REDIS_PASSWORD=CLICKHOUSE_HOST=http://localhostCLICKHOUSE_USER=defaultCLICKHOUSE_PORT=8123-CLICKHOUSE_PASSWORD=password+CLICKHOUSE_PASSWORD=CLICKHOUSE_DATABASE=analytics# Leave empty for all originsAPI_ORIGINS=@@ -49,4 +49,4 @@ TG_BOT_TOKEN=# Swetrix CDN for storing filesCDN_URL=http://localhost:5006-CDN_ACCESS_TOKEN=SOME_SECRET_TOKEN\ No newline at end of file+CDN_ACCESS_TOKEN=SOME_SECRET_TOKENdiff --git a/docker-compose.yml b/docker-compose.ymlindex 5069b87f8..241835e2c 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -1,29 +1,19 @@-version: ${DOCKER_COMPOSE_VERSION}+version: '3.8'services:+ redis:+ image: redis:7.0.8+ ports:+ - 6379:6379mysql:- image: mysql:${MYSQL_VERSION}- container_name: swetrix-api-mysql+ image: mysql:8.0.32environment:- - MYSQL_ALLOW_EMPTY_PASSWORD=yes+ MYSQL_DATABASE: 'analytics'+ MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'ports:- - ${MYSQL_PORT}:3306- redis:- image: redis:${REDIS_VERSION}- container_name: swetrix-api-redis- ports:- - ${REDIS_PORT}:6379+ - 3306:3306clickhouse:- image: clickhouse/clickhouse-server:${CLICKHOUSE_VERSION}- container_name: swetrix-api-clickhouse- ports:- - ${CLICKHOUSE_PORT}:8123- redis-commander:- image: rediscommander/redis-commander:${REDIS_COMMANDER_VERSION}- container_name: swetrix-api-redis-commander+ image: clickhouse/clickhouse-server:23.1.3.5environment:- - REDIS_HOSTS=redis+ CLICKHOUSE_DB: 'analytics'ports:- - ${REDIS_COMMANDER_PORT}:8081-networks:- default:- name: swetrix-api\ No newline at end of file+ - 8123:8123diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.tsindex 5aab5a065..5e84bb013 100644--- a/src/auth/auth.controller.ts+++ b/src/auth/auth.controller.ts@@ -139,7 +139,10 @@ export class AuthController {await this.authService.sendTelegramNotification(user.id, headers, ip)- const jwtTokens = await this.authService.generateJwtTokens(user.id, !user.isTwoFactorAuthenticationEnabled)+ const jwtTokens = await this.authService.generateJwtTokens(+ user.id,+ !user.isTwoFactorAuthenticationEnabled,+ )if (user.isTwoFactorAuthenticationEnabled) {user = _pick(user, ['isTwoFactorAuthenticationEnabled', 'email'])diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.tsindex a750d4631..d8aa36ebc 100644--- a/src/auth/auth.service.ts+++ b/src/auth/auth.service.ts@@ -85,9 +85,9 @@ export class AuthService {})}- const verificationLink = `${this.configService.get(- 'CLIENT_URL',- )}/verify/${actionToken.id}`+ const verificationLink = `${this.configService.get('CLIENT_URL')}/verify/${+ actionToken.id+ }`await this.mailerService.sendEmail(email, LetterTemplate.SignUp, {url: verificationLink,diff --git a/src/auth/dtos/login.dto.ts b/src/auth/dtos/login.dto.tsindex ff3b0d7f8..62ed65270 100644--- a/src/auth/dtos/login.dto.ts+++ b/src/auth/dtos/login.dto.ts@@ -1,24 +1,23 @@-import {- ApiProperty,- IntersectionType,- OmitType,- PickType,-} from '@nestjs/swagger'-import { RegisterRequestDto, RegisterResponseDto } from './register.dto'+import { ApiProperty, OmitType } from '@nestjs/swagger'+import { RegisterRequestDto } from './register.dto'export class LoginRequestDto extends OmitType(RegisterRequestDto, ['checkIfLeaked',] as const) {}-class AdditionalInfo {+export class LoginResponseDto {+ @ApiProperty({+ description: 'Access token (JWT)',+ })+ public readonly accessToken: string++ @ApiProperty({+ description: 'Refresh token (JWT)',+ })+ public readonly refreshToken: string+@ApiProperty({description: 'User entity',- example: false,})user: object}--export class LoginResponseDto extends IntersectionType(- PickType(RegisterResponseDto, ['accessToken', 'refreshToken'] as const),- AdditionalInfo,-) {}diff --git a/src/auth/guards/api-key-rate-limit.guard.ts b/src/auth/guards/api-key-rate-limit.guard.tsindex f6a029df9..da9596fa3 100644--- a/src/auth/guards/api-key-rate-limit.guard.ts+++ b/src/auth/guards/api-key-rate-limit.guard.ts@@ -11,7 +11,8 @@ export class ApiKeyRateLimitGuard implements CanActivate {if (request.headers['x-api-key']) {if (!user) return false- const reqAmount = ACCOUNT_PLANS[user.planCode as PlanCode].maxApiKeyRequestsPerHour+ const reqAmount =+ ACCOUNT_PLANS[user.planCode as PlanCode].maxApiKeyRequestsPerHourreturn await checkRateLimitForApiKey(user.apiKey, reqAmount)}