Skip to content

📈 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!

change application structure to monorepo-style

Blue Mousecd63ee496b71
diff --git a/.gitignore b/.gitignore
index b8004f0d2..18b2e24e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
# compiled output
-/dist
-/node_modules
+dist
+node_modules
# Logs
logs
diff --git a/src/Util/Util.ts b/apps/production/src/Util/Util.ts
similarity index 100%
rename from src/Util/Util.ts
rename to apps/production/src/Util/Util.ts
diff --git a/src/action-tokens/action-token.entity.ts b/apps/production/src/action-tokens/action-token.entity.ts
similarity index 100%
rename from src/action-tokens/action-token.entity.ts
rename to apps/production/src/action-tokens/action-token.entity.ts
diff --git a/src/action-tokens/action-tokens.module.ts b/apps/production/src/action-tokens/action-tokens.module.ts
similarity index 100%
rename from src/action-tokens/action-tokens.module.ts
rename to apps/production/src/action-tokens/action-tokens.module.ts
diff --git a/src/action-tokens/action-tokens.service.spec.ts b/apps/production/src/action-tokens/action-tokens.service.spec.ts
similarity index 100%
rename from src/action-tokens/action-tokens.service.spec.ts
rename to apps/production/src/action-tokens/action-tokens.service.spec.ts
diff --git a/src/action-tokens/action-tokens.service.ts b/apps/production/src/action-tokens/action-tokens.service.ts
similarity index 100%
rename from src/action-tokens/action-tokens.service.ts
rename to apps/production/src/action-tokens/action-tokens.service.ts
diff --git a/src/alert/alert.controller.ts b/apps/production/src/alert/alert.controller.ts
similarity index 100%
rename from src/alert/alert.controller.ts
rename to apps/production/src/alert/alert.controller.ts
diff --git a/src/alert/alert.module.ts b/apps/production/src/alert/alert.module.ts
similarity index 100%
rename from src/alert/alert.module.ts
rename to apps/production/src/alert/alert.module.ts
diff --git a/src/alert/alert.service.spec.ts b/apps/production/src/alert/alert.service.spec.ts
similarity index 100%
rename from src/alert/alert.service.spec.ts
rename to apps/production/src/alert/alert.service.spec.ts
diff --git a/src/alert/alert.service.ts b/apps/production/src/alert/alert.service.ts
similarity index 96%
rename from src/alert/alert.service.ts
rename to apps/production/src/alert/alert.service.ts
index a215b6627..9d7527b5f 100644
--- a/src/alert/alert.service.ts
+++ b/apps/production/src/alert/alert.service.ts
@@ -1,7 +1,10 @@
import { Injectable } from '@nestjs/common'
import { InjectRepository } from '@nestjs/typeorm'
import { Repository } from 'typeorm'
-import { Pagination, PaginationOptionsInterface } from 'src/common/pagination'
+import {
+ Pagination,
+ PaginationOptionsInterface,
+} from 'src/common/pagination'
import { Alert } from './entity/alert.entity'
import { AlertDTO } from './dto/alert.dto'
diff --git a/src/alert/dto/alert.dto.ts b/apps/production/src/alert/dto/alert.dto.ts
similarity index 100%
rename from src/alert/dto/alert.dto.ts
rename to apps/production/src/alert/dto/alert.dto.ts
diff --git a/src/alert/entity/alert.entity.ts b/apps/production/src/alert/entity/alert.entity.ts
similarity index 93%
rename from src/alert/entity/alert.entity.ts
rename to apps/production/src/alert/entity/alert.entity.ts
index 4cede0045..dddce5cc2 100644
--- a/src/alert/entity/alert.entity.ts
+++ b/apps/production/src/alert/entity/alert.entity.ts
@@ -2,7 +2,11 @@ import { Entity, Column, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'
import { ApiProperty } from '@nestjs/swagger'
import { Project } from 'src/project/entity/project.entity'
-import { QueryCondition, QueryMetric, QueryTime } from 'src/alert/dto/alert.dto'
+import {
+ QueryCondition,
+ QueryMetric,
+ QueryTime,
+} from 'src/alert/dto/alert.dto'
@Entity()
export class Alert {
diff --git a/src/analytics/analytics.controller.spec.ts b/apps/production/src/analytics/analytics.controller.spec.ts
similarity index 100%
rename from src/analytics/analytics.controller.spec.ts
rename to apps/production/src/analytics/analytics.controller.spec.ts
diff --git a/src/analytics/analytics.controller.ts b/apps/production/src/analytics/analytics.controller.ts
similarity index 100%
rename from src/analytics/analytics.controller.ts
rename to apps/production/src/analytics/analytics.controller.ts
diff --git a/selfhosted-src/analytics/analytics.module.ts b/apps/production/src/analytics/analytics.module.ts
similarity index 100%
rename from selfhosted-src/analytics/analytics.module.ts
rename to apps/production/src/analytics/analytics.module.ts
diff --git a/src/analytics/analytics.service.spec.ts b/apps/production/src/analytics/analytics.service.spec.ts
similarity index 100%
rename from src/analytics/analytics.service.spec.ts
rename to apps/production/src/analytics/analytics.service.spec.ts
diff --git a/src/analytics/analytics.service.ts b/apps/production/src/analytics/analytics.service.ts
similarity index 98%
rename from src/analytics/analytics.service.ts
rename to apps/production/src/analytics/analytics.service.ts
index ffe51e76c..313be460a 100644
--- a/src/analytics/analytics.service.ts
+++ b/apps/production/src/analytics/analytics.service.ts
@@ -321,21 +321,21 @@ export class AnalyticsService {
)
}
- if (project.admin.planCode === PlanCode.none) {
- throw new ForbiddenException(
- 'You cannot send analytics to this project due to no active subscription. Please upgrade your account plan to continue sending analytics.',
- )
- }
+ if (project.admin.planCode === PlanCode.none) {
+ throw new ForbiddenException(
+ 'You cannot send analytics to this project due to no active subscription. Please upgrade your account plan to continue sending analytics.',
+ )
+ }
- const count = await this.projectService.getRedisCount(project.admin.id)
- const maxCount =
- ACCOUNT_PLANS[project.admin.planCode].monthlyUsageLimit || 0
+ const count = await this.projectService.getRedisCount(project.admin.id)
+ const maxCount =
+ ACCOUNT_PLANS[project.admin.planCode].monthlyUsageLimit || 0
- if (count >= maxCount) {
- throw new ForbiddenException(
- 'You have exceeded the available monthly request limit for your account. Please upgrade your account plan if you need more requests.',
- )
- }
+ if (count >= maxCount) {
+ throw new ForbiddenException(
+ 'You have exceeded the available monthly request limit for your account. Please upgrade your account plan if you need more requests.',
+ )
+ }
this.checkOrigin(project, origin)
diff --git a/selfhosted-src/analytics/dto/events.dto.ts b/apps/production/src/analytics/dto/events.dto.ts
similarity index 100%
rename from selfhosted-src/analytics/dto/events.dto.ts
rename to apps/production/src/analytics/dto/events.dto.ts
diff --git a/selfhosted-src/analytics/dto/get-custom-events.dto.ts b/apps/production/src/analytics/dto/get-custom-events.dto.ts
similarity index 100%
rename from selfhosted-src/analytics/dto/get-custom-events.dto.ts
rename to apps/production/src/analytics/dto/get-custom-events.dto.ts
diff --git a/selfhosted-src/analytics/dto/getData.dto.ts b/apps/production/src/analytics/dto/getData.dto.ts
similarity index 100%
rename from selfhosted-src/analytics/dto/getData.dto.ts
rename to apps/production/src/analytics/dto/getData.dto.ts
diff --git a/selfhosted-src/analytics/dto/getUserFlow.dto.ts b/apps/production/src/analytics/dto/getUserFlow.dto.ts
similarity index 100%
rename from selfhosted-src/analytics/dto/getUserFlow.dto.ts
rename to apps/production/src/analytics/dto/getUserFlow.dto.ts
diff --git a/selfhosted-src/analytics/dto/pageviews.dto.ts b/apps/production/src/analytics/dto/pageviews.dto.ts
similarity index 100%
rename from selfhosted-src/analytics/dto/pageviews.dto.ts
rename to apps/production/src/analytics/dto/pageviews.dto.ts
diff --git a/selfhosted-src/analytics/interfaces/index.ts b/apps/production/src/analytics/interfaces/index.ts
similarity index 100%
rename from selfhosted-src/analytics/interfaces/index.ts
rename to apps/production/src/analytics/interfaces/index.ts
diff --git a/src/app.module.ts b/apps/production/src/app.module.ts
similarity index 100%
rename from src/app.module.ts
rename to apps/production/src/app.module.ts
diff --git a/src/auth/auth.controller.spec.ts b/apps/production/src/auth/auth.controller.spec.ts
similarity index 100%
rename from src/auth/auth.controller.spec.ts
rename to apps/production/src/auth/auth.controller.spec.ts
diff --git a/src/auth/auth.controller.ts b/apps/production/src/auth/auth.controller.ts
similarity index 99%
rename from src/auth/auth.controller.ts
rename to apps/production/src/auth/auth.controller.ts
index 1f87e49d4..63ea66f77 100644
--- a/src/auth/auth.controller.ts
+++ b/apps/production/src/auth/auth.controller.ts
@@ -27,10 +27,7 @@ import { I18nValidationExceptionFilter, I18n, I18nContext } from 'nestjs-i18n'
import * as _pick from 'lodash/pick'
import { checkRateLimit } from 'src/common/utils'
-import {
- UserType,
- User,
-} from 'src/user/entities/user.entity'
+import { UserType, User } from 'src/user/entities/user.entity'
import { UserService } from 'src/user/user.service'
import { AuthService } from './auth.service'
import { Public, CurrentUserId, CurrentUser, Roles } from './decorators'
diff --git a/src/auth/auth.module.ts b/apps/production/src/auth/auth.module.ts
similarity index 100%
rename from src/auth/auth.module.ts
rename to apps/production/src/auth/auth.module.ts
diff --git a/src/auth/auth.service.spec.ts b/apps/production/src/auth/auth.service.spec.ts
similarity index 100%
rename from src/auth/auth.service.spec.ts
rename to apps/production/src/auth/auth.service.spec.ts
diff --git a/src/auth/auth.service.ts b/apps/production/src/auth/auth.service.ts
similarity index 99%
rename from src/auth/auth.service.ts
rename to apps/production/src/auth/auth.service.ts
index 752ad5640..aefae0338 100644
--- a/src/auth/auth.service.ts
+++ b/apps/production/src/auth/auth.service.ts
@@ -425,7 +425,7 @@ export class AuthService {
},
)
- await this.userService.saveRefreshToken(userId, refreshToken)
+ await this.userService.saveRefreshToken(userId, refreshToken)
return refreshToken
}
diff --git a/src/auth/decorators/auth.decorator.ts b/apps/production/src/auth/decorators/auth.decorator.ts
similarity index 100%
rename from src/auth/decorators/auth.decorator.ts
rename to apps/production/src/auth/decorators/auth.decorator.ts
diff --git a/selfhosted-src/auth/decorators/current-user-id.decorator.ts b/apps/production/src/auth/decorators/current-user-id.decorator.ts
similarity index 100%
rename from selfhosted-src/auth/decorators/current-user-id.decorator.ts
rename to apps/production/src/auth/decorators/current-user-id.decorator.ts
diff --git a/selfhosted-src/auth/decorators/current-user.decorator.ts b/apps/production/src/auth/decorators/current-user.decorator.ts
similarity index 100%
rename from selfhosted-src/auth/decorators/current-user.decorator.ts
rename to apps/production/src/auth/decorators/current-user.decorator.ts
diff --git a/selfhosted-src/auth/decorators/index.ts b/apps/production/src/auth/decorators/index.ts
similarity index 100%
rename from selfhosted-src/auth/decorators/index.ts
rename to apps/production/src/auth/decorators/index.ts
diff --git a/selfhosted-src/auth/decorators/public.decorator.ts b/apps/production/src/auth/decorators/public.decorator.ts
similarity index 100%
rename from selfhosted-src/auth/decorators/public.decorator.ts
rename to apps/production/src/auth/decorators/public.decorator.ts
diff --git a/src/auth/decorators/roles.decorator.ts b/apps/production/src/auth/decorators/roles.decorator.ts
similarity index 100%
rename from src/auth/decorators/roles.decorator.ts
rename to apps/production/src/auth/decorators/roles.decorator.ts
diff --git a/selfhosted-src/auth/decorators/two-fa-not-required.decorator.ts b/apps/production/src/auth/decorators/two-fa-not-required.decorator.ts
similarity index 100%
rename from selfhosted-src/auth/decorators/two-fa-not-required.decorator.ts
rename to apps/production/src/auth/decorators/two-fa-not-required.decorator.ts
diff --git a/selfhosted-src/auth/dtos/change-password.dto.ts b/apps/production/src/auth/dtos/change-password.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/change-password.dto.ts
rename to apps/production/src/auth/dtos/change-password.dto.ts
diff --git a/selfhosted-src/auth/dtos/confirm-change-email.dto.ts b/apps/production/src/auth/dtos/confirm-change-email.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/confirm-change-email.dto.ts
rename to apps/production/src/auth/dtos/confirm-change-email.dto.ts
diff --git a/selfhosted-src/auth/dtos/confirm-reset-password.dto.ts b/apps/production/src/auth/dtos/confirm-reset-password.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/confirm-reset-password.dto.ts
rename to apps/production/src/auth/dtos/confirm-reset-password.dto.ts
diff --git a/selfhosted-src/auth/dtos/index.ts b/apps/production/src/auth/dtos/index.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/index.ts
rename to apps/production/src/auth/dtos/index.ts
diff --git a/selfhosted-src/auth/dtos/login.dto.ts b/apps/production/src/auth/dtos/login.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/login.dto.ts
rename to apps/production/src/auth/dtos/login.dto.ts
diff --git a/selfhosted-src/auth/dtos/process-sso-code.dto.ts b/apps/production/src/auth/dtos/process-sso-code.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/process-sso-code.dto.ts
rename to apps/production/src/auth/dtos/process-sso-code.dto.ts
diff --git a/selfhosted-src/auth/dtos/register.dto.ts b/apps/production/src/auth/dtos/register.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/register.dto.ts
rename to apps/production/src/auth/dtos/register.dto.ts
diff --git a/selfhosted-src/auth/dtos/request-change-email.dto.ts b/apps/production/src/auth/dtos/request-change-email.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/request-change-email.dto.ts
rename to apps/production/src/auth/dtos/request-change-email.dto.ts
diff --git a/selfhosted-src/auth/dtos/request-reset-password.dto.ts b/apps/production/src/auth/dtos/request-reset-password.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/request-reset-password.dto.ts
rename to apps/production/src/auth/dtos/request-reset-password.dto.ts
diff --git a/selfhosted-src/auth/dtos/reset-password.dto.ts b/apps/production/src/auth/dtos/reset-password.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/reset-password.dto.ts
rename to apps/production/src/auth/dtos/reset-password.dto.ts
diff --git a/selfhosted-src/auth/dtos/sso-generate.dto.ts b/apps/production/src/auth/dtos/sso-generate.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/sso-generate.dto.ts
rename to apps/production/src/auth/dtos/sso-generate.dto.ts
diff --git a/selfhosted-src/auth/dtos/sso-get-jwt-by-hash.dto.ts b/apps/production/src/auth/dtos/sso-get-jwt-by-hash.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/sso-get-jwt-by-hash.dto.ts
rename to apps/production/src/auth/dtos/sso-get-jwt-by-hash.dto.ts
diff --git a/selfhosted-src/auth/dtos/sso-link.dto.ts b/apps/production/src/auth/dtos/sso-link.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/sso-link.dto.ts
rename to apps/production/src/auth/dtos/sso-link.dto.ts
diff --git a/selfhosted-src/auth/dtos/sso-unlink.dto.ts b/apps/production/src/auth/dtos/sso-unlink.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/sso-unlink.dto.ts
rename to apps/production/src/auth/dtos/sso-unlink.dto.ts
diff --git a/selfhosted-src/auth/dtos/verify-email.dto.ts b/apps/production/src/auth/dtos/verify-email.dto.ts
similarity index 100%
rename from selfhosted-src/auth/dtos/verify-email.dto.ts
rename to apps/production/src/auth/dtos/verify-email.dto.ts
diff --git a/src/auth/guards/api-key-rate-limit.guard.ts b/apps/production/src/auth/guards/api-key-rate-limit.guard.ts
similarity index 88%
rename from src/auth/guards/api-key-rate-limit.guard.ts
rename to apps/production/src/auth/guards/api-key-rate-limit.guard.ts
index 8ce458501..96b762c5c 100644
--- a/src/auth/guards/api-key-rate-limit.guard.ts
+++ b/apps/production/src/auth/guards/api-key-rate-limit.guard.ts
@@ -1,6 +1,9 @@
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'
import { checkRateLimitForApiKey } from 'src/common/utils'
-import { ACCOUNT_PLANS, PlanCode } from 'src/user/entities/user.entity'
+import {
+ ACCOUNT_PLANS,
+ PlanCode,
+} from 'src/user/entities/user.entity'
@Injectable()
export class ApiKeyRateLimitGuard implements CanActivate {
diff --git a/selfhosted-src/auth/guards/api-key.guard.ts b/apps/production/src/auth/guards/api-key.guard.ts
similarity index 100%
rename from selfhosted-src/auth/guards/api-key.guard.ts
rename to apps/production/src/auth/guards/api-key.guard.ts
diff --git a/selfhosted-src/auth/guards/index.ts b/apps/production/src/auth/guards/index.ts
similarity index 100%
rename from selfhosted-src/auth/guards/index.ts
rename to apps/production/src/auth/guards/index.ts
diff --git a/selfhosted-src/auth/guards/jwt-access-token.guard.ts b/apps/production/src/auth/guards/jwt-access-token.guard.ts
similarity index 100%
rename from selfhosted-src/auth/guards/jwt-access-token.guard.ts
rename to apps/production/src/auth/guards/jwt-access-token.guard.ts
diff --git a/selfhosted-src/auth/guards/jwt-refresh-token.guard.ts b/apps/production/src/auth/guards/jwt-refresh-token.guard.ts
similarity index 100%
rename from selfhosted-src/auth/guards/jwt-refresh-token.guard.ts
rename to apps/production/src/auth/guards/jwt-refresh-token.guard.ts
diff --git a/selfhosted-src/auth/guards/multi-auth.guard.ts b/apps/production/src/auth/guards/multi-auth.guard.ts
similarity index 100%
rename from selfhosted-src/auth/guards/multi-auth.guard.ts
rename to apps/production/src/auth/guards/multi-auth.guard.ts
diff --git a/selfhosted-src/auth/guards/optional-jwt-access-token.guard.ts b/apps/production/src/auth/guards/optional-jwt-access-token.guard.ts
similarity index 100%
rename from selfhosted-src/auth/guards/optional-jwt-access-token.guard.ts
rename to apps/production/src/auth/guards/optional-jwt-access-token.guard.ts
diff --git a/src/auth/guards/roles.guard.ts b/apps/production/src/auth/guards/roles.guard.ts
similarity index 100%
rename from src/auth/guards/roles.guard.ts
rename to apps/production/src/auth/guards/roles.guard.ts
diff --git a/selfhosted-src/auth/interfaces/index.ts b/apps/production/src/auth/interfaces/index.ts
similarity index 100%
rename from selfhosted-src/auth/interfaces/index.ts
rename to apps/production/src/auth/interfaces/index.ts
diff --git a/selfhosted-src/auth/interfaces/jwt-payload.interface.ts b/apps/production/src/auth/interfaces/jwt-payload.interface.ts
similarity index 100%
rename from selfhosted-src/auth/interfaces/jwt-payload.interface.ts
rename to apps/production/src/auth/interfaces/jwt-payload.interface.ts
diff --git a/selfhosted-src/auth/strategies/api-key.strategy.ts b/apps/production/src/auth/strategies/api-key.strategy.ts
similarity index 100%
rename from selfhosted-src/auth/strategies/api-key.strategy.ts
rename to apps/production/src/auth/strategies/api-key.strategy.ts
diff --git a/selfhosted-src/auth/strategies/index.ts b/apps/production/src/auth/strategies/index.ts
similarity index 100%
rename from selfhosted-src/auth/strategies/index.ts
rename to apps/production/src/auth/strategies/index.ts
diff --git a/src/auth/strategies/jwt-access-token.strategy.ts b/apps/production/src/auth/strategies/jwt-access-token.strategy.ts
similarity index 93%
rename from src/auth/strategies/jwt-access-token.strategy.ts
rename to apps/production/src/auth/strategies/jwt-access-token.strategy.ts
index 160c51551..f1aac8a2e 100644
--- a/src/auth/strategies/jwt-access-token.strategy.ts
+++ b/apps/production/src/auth/strategies/jwt-access-token.strategy.ts
@@ -3,9 +3,7 @@ import { ConfigService } from '@nestjs/config'
import { PassportStrategy } from '@nestjs/passport'
import { Strategy, ExtractJwt } from 'passport-jwt'
-import {
- JWT_ACCESS_TOKEN_SECRET,
-} from 'src/common/constants'
+import { JWT_ACCESS_TOKEN_SECRET } from 'src/common/constants'
import { UserService } from 'src/user/user.service'
import { IJwtPayload } from '../interfaces'
diff --git a/selfhosted-src/auth/strategies/jwt-refresh-token.strategy.ts b/apps/production/src/auth/strategies/jwt-refresh-token.strategy.ts
similarity index 100%
rename from selfhosted-src/auth/strategies/jwt-refresh-token.strategy.ts
rename to apps/production/src/auth/strategies/jwt-refresh-token.strategy.ts
diff --git a/src/captcha/captcha.controller.spec.ts b/apps/production/src/captcha/captcha.controller.spec.ts
similarity index 100%
rename from src/captcha/captcha.controller.spec.ts
rename to apps/production/src/captcha/captcha.controller.spec.ts
diff --git a/src/captcha/captcha.controller.ts b/apps/production/src/captcha/captcha.controller.ts
similarity index 100%
rename from src/captcha/captcha.controller.ts
rename to apps/production/src/captcha/captcha.controller.ts
diff --git a/src/captcha/captcha.module.ts b/apps/production/src/captcha/captcha.module.ts
similarity index 100%
rename from src/captcha/captcha.module.ts
rename to apps/production/src/captcha/captcha.module.ts
diff --git a/src/captcha/captcha.service.ts b/apps/production/src/captcha/captcha.service.ts
similarity index 100%
rename from src/captcha/captcha.service.ts
rename to apps/production/src/captcha/captcha.service.ts
diff --git a/src/captcha/dtos/automatic.dto.ts b/apps/production/src/captcha/dtos/automatic.dto.ts
similarity index 100%
rename from src/captcha/dtos/automatic.dto.ts
rename to apps/production/src/captcha/dtos/automatic.dto.ts
diff --git a/src/captcha/dtos/generate.dto.ts b/apps/production/src/captcha/dtos/generate.dto.ts
similarity index 100%
rename from src/captcha/dtos/generate.dto.ts
rename to apps/production/src/captcha/dtos/generate.dto.ts
diff --git a/src/captcha/dtos/manual.dto.ts b/apps/production/src/captcha/dtos/manual.dto.ts
similarity index 100%
rename from src/captcha/dtos/manual.dto.ts
rename to apps/production/src/captcha/dtos/manual.dto.ts
diff --git a/src/captcha/dtos/validate.dto.ts b/apps/production/src/captcha/dtos/validate.dto.ts
similarity index 100%
rename from src/captcha/dtos/validate.dto.ts
rename to apps/production/src/captcha/dtos/validate.dto.ts
diff --git a/src/captcha/interfaces/generated-captcha.ts b/apps/production/src/captcha/interfaces/generated-captcha.ts
similarity index 100%
rename from src/captcha/interfaces/generated-captcha.ts
rename to apps/production/src/captcha/interfaces/generated-captcha.ts
diff --git a/src/captcha/interfaces/token-captcha.ts b/apps/production/src/captcha/interfaces/token-captcha.ts
similarity index 100%
rename from src/captcha/interfaces/token-captcha.ts
rename to apps/production/src/captcha/interfaces/token-captcha.ts
diff --git a/src/common/constants.ts b/apps/production/src/common/constants.ts
similarity index 100%
rename from src/common/constants.ts
rename to apps/production/src/common/constants.ts
diff --git a/selfhosted-src/common/decorators/bot-detection.decorator.ts b/apps/production/src/common/decorators/bot-detection.decorator.ts
similarity index 100%
rename from selfhosted-src/common/decorators/bot-detection.decorator.ts
rename to apps/production/src/common/decorators/bot-detection.decorator.ts
diff --git a/selfhosted-src/common/guards/bot-detection.guard.ts b/apps/production/src/common/guards/bot-detection.guard.ts
similarity index 100%
rename from selfhosted-src/common/guards/bot-detection.guard.ts
rename to apps/production/src/common/guards/bot-detection.guard.ts
diff --git a/src/common/interceptors/newrelic.interceptor.ts b/apps/production/src/common/interceptors/newrelic.interceptor.ts
similarity index 100%
rename from src/common/interceptors/newrelic.interceptor.ts
rename to apps/production/src/common/interceptors/newrelic.interceptor.ts
diff --git a/selfhosted-src/common/pagination/index.ts b/apps/production/src/common/pagination/index.ts
similarity index 100%
rename from selfhosted-src/common/pagination/index.ts
rename to apps/production/src/common/pagination/index.ts
diff --git a/selfhosted-src/common/pagination/pagination.options.interface.ts b/apps/production/src/common/pagination/pagination.options.interface.ts
similarity index 100%
rename from selfhosted-src/common/pagination/pagination.options.interface.ts
rename to apps/production/src/common/pagination/pagination.options.interface.ts
diff --git a/selfhosted-src/common/pagination/pagination.results.interface.ts b/apps/production/src/common/pagination/pagination.results.interface.ts
similarity index 100%
rename from selfhosted-src/common/pagination/pagination.results.interface.ts
rename to apps/production/src/common/pagination/pagination.results.interface.ts
diff --git a/selfhosted-src/common/pagination/pagination.ts b/apps/production/src/common/pagination/pagination.ts
similarity index 100%
rename from selfhosted-src/common/pagination/pagination.ts
rename to apps/production/src/common/pagination/pagination.ts
diff --git a/src/common/templates/en/2fa-turned-off.html b/apps/production/src/common/templates/en/2fa-turned-off.html
similarity index 100%
rename from src/common/templates/en/2fa-turned-off.html
rename to apps/production/src/common/templates/en/2fa-turned-off.html
diff --git a/src/common/templates/en/2fa-turned-on.html b/apps/production/src/common/templates/en/2fa-turned-on.html
similarity index 100%
rename from src/common/templates/en/2fa-turned-on.html
rename to apps/production/src/common/templates/en/2fa-turned-on.html
diff --git a/src/common/templates/en/customer_project-invitation.html b/apps/production/src/common/templates/en/customer_project-invitation.html
similarity index 100%
rename from src/common/templates/en/customer_project-invitation.html
rename to apps/production/src/common/templates/en/customer_project-invitation.html
diff --git a/src/common/templates/en/customer_sign-up.html b/apps/production/src/common/templates/en/customer_sign-up.html
similarity index 100%
rename from src/common/templates/en/customer_sign-up.html
rename to apps/production/src/common/templates/en/customer_sign-up.html
diff --git a/src/common/templates/en/gdpr_data_export.html b/apps/production/src/common/templates/en/gdpr_data_export.html
similarity index 100%
rename from src/common/templates/en/gdpr_data_export.html
rename to apps/production/src/common/templates/en/gdpr_data_export.html
diff --git a/src/common/templates/en/mailaddress-change_confirmation.html b/apps/production/src/common/templates/en/mailaddress-change_confirmation.html
similarity index 100%
rename from src/common/templates/en/mailaddress-change_confirmation.html
rename to apps/production/src/common/templates/en/mailaddress-change_confirmation.html
diff --git a/src/common/templates/en/mailaddress-change_information.html b/apps/production/src/common/templates/en/mailaddress-change_information.html
similarity index 100%
rename from src/common/templates/en/mailaddress-change_information.html
rename to apps/production/src/common/templates/en/mailaddress-change_information.html
diff --git a/src/common/templates/en/password-change_confirmation.html b/apps/production/src/common/templates/en/password-change_confirmation.html
similarity index 100%
rename from src/common/templates/en/password-change_confirmation.html
rename to apps/production/src/common/templates/en/password-change_confirmation.html
diff --git a/src/common/templates/en/password-change_information.html b/apps/production/src/common/templates/en/password-change_information.html
similarity index 100%
rename from src/common/templates/en/password-change_information.html
rename to apps/production/src/common/templates/en/password-change_information.html
diff --git a/src/common/templates/en/password-change_request.html b/apps/production/src/common/templates/en/password-change_request.html
similarity index 100%
rename from src/common/templates/en/password-change_request.html
rename to apps/production/src/common/templates/en/password-change_request.html
diff --git a/src/common/templates/en/project-report.html b/apps/production/src/common/templates/en/project-report.html
similarity index 100%
rename from src/common/templates/en/project-report.html
rename to apps/production/src/common/templates/en/project-report.html
diff --git a/src/common/templates/en/project-subscriber-invitation.html b/apps/production/src/common/templates/en/project-subscriber-invitation.html
similarity index 100%
rename from src/common/templates/en/project-subscriber-invitation.html
rename to apps/production/src/common/templates/en/project-subscriber-invitation.html
diff --git a/src/common/templates/en/project-transfer.html b/apps/production/src/common/templates/en/project-transfer.html
similarity index 100%
rename from src/common/templates/en/project-transfer.html
rename to apps/production/src/common/templates/en/project-transfer.html
diff --git a/src/common/templates/en/tier-warning.html b/apps/production/src/common/templates/en/tier-warning.html
similarity index 100%
rename from src/common/templates/en/tier-warning.html
rename to apps/production/src/common/templates/en/tier-warning.html
diff --git a/src/common/templates/en/trial-ends-tomorrow.html b/apps/production/src/common/templates/en/trial-ends-tomorrow.html
similarity index 100%
rename from src/common/templates/en/trial-ends-tomorrow.html
rename to apps/production/src/common/templates/en/trial-ends-tomorrow.html
diff --git a/src/common/templates/en/trial-expired.html b/apps/production/src/common/templates/en/trial-expired.html
similarity index 100%
rename from src/common/templates/en/trial-expired.html
rename to apps/production/src/common/templates/en/trial-expired.html
diff --git a/src/common/utils.ts b/apps/production/src/common/utils.ts
similarity index 99%
rename from src/common/utils.ts
rename to apps/production/src/common/utils.ts
index e7ba78fcd..12b622129 100644
--- a/src/common/utils.ts
+++ b/apps/production/src/common/utils.ts
@@ -5,10 +5,7 @@ import * as _sample from 'lodash/sample'
import * as _toNumber from 'lodash/toNumber'
import * as _round from 'lodash/round'
-import {
- redis,
- isDevelopment,
-} from './constants'
+import { redis, isDevelopment } from './constants'
const marketingTips = {
en: [
diff --git a/selfhosted-src/configs/i18n.config.ts b/apps/production/src/configs/i18n.config.ts
similarity index 100%
rename from selfhosted-src/configs/i18n.config.ts
rename to apps/production/src/configs/i18n.config.ts
diff --git a/selfhosted-src/configs/index.ts b/apps/production/src/configs/index.ts
similarity index 100%
rename from selfhosted-src/configs/index.ts
rename to apps/production/src/configs/index.ts
diff --git a/selfhosted-src/i18n/en/auth.json b/apps/production/src/i18n/en/auth.json
similarity index 100%
rename from selfhosted-src/i18n/en/auth.json
rename to apps/production/src/i18n/en/auth.json
diff --git a/selfhosted-src/i18n/en/user.json b/apps/production/src/i18n/en/user.json
similarity index 100%
rename from selfhosted-src/i18n/en/user.json
rename to apps/production/src/i18n/en/user.json
diff --git a/selfhosted-src/i18n/en/validation.json b/apps/production/src/i18n/en/validation.json
similarity index 100%
rename from selfhosted-src/i18n/en/validation.json
rename to apps/production/src/i18n/en/validation.json
diff --git a/src/integrations/integrations.module.ts b/apps/production/src/integrations/integrations.module.ts
similarity index 100%
rename from src/integrations/integrations.module.ts
rename to apps/production/src/integrations/integrations.module.ts
diff --git a/src/integrations/telegram/interface/context.interface.ts b/apps/production/src/integrations/telegram/interface/context.interface.ts
similarity index 100%
rename from src/integrations/telegram/interface/context.interface.ts
rename to apps/production/src/integrations/telegram/interface/context.interface.ts
diff --git a/src/integrations/telegram/scene/projects.scene.ts b/apps/production/src/integrations/telegram/scene/projects.scene.ts
similarity index 100%
rename from src/integrations/telegram/scene/projects.scene.ts
rename to apps/production/src/integrations/telegram/scene/projects.scene.ts
diff --git a/src/integrations/telegram/scene/settings.scene.ts b/apps/production/src/integrations/telegram/scene/settings.scene.ts
similarity index 100%
rename from src/integrations/telegram/scene/settings.scene.ts
rename to apps/production/src/integrations/telegram/scene/settings.scene.ts
diff --git a/src/integrations/telegram/scene/start.scene.ts b/apps/production/src/integrations/telegram/scene/start.scene.ts
similarity index 100%
rename from src/integrations/telegram/scene/start.scene.ts
rename to apps/production/src/integrations/telegram/scene/start.scene.ts
diff --git a/src/integrations/telegram/scene/unlink-account.scene.ts b/apps/production/src/integrations/telegram/scene/unlink-account.scene.ts
similarity index 100%
rename from src/integrations/telegram/scene/unlink-account.scene.ts
rename to apps/production/src/integrations/telegram/scene/unlink-account.scene.ts
diff --git a/src/integrations/telegram/telegram.controller.ts b/apps/production/src/integrations/telegram/telegram.controller.ts
similarity index 100%
rename from src/integrations/telegram/telegram.controller.ts
rename to apps/production/src/integrations/telegram/telegram.controller.ts
diff --git a/src/integrations/telegram/telegram.module.ts b/apps/production/src/integrations/telegram/telegram.module.ts
similarity index 100%
rename from src/integrations/telegram/telegram.module.ts
rename to apps/production/src/integrations/telegram/telegram.module.ts
diff --git a/src/integrations/telegram/telegram.service.ts b/apps/production/src/integrations/telegram/telegram.service.ts
similarity index 100%
rename from src/integrations/telegram/telegram.service.ts
rename to apps/production/src/integrations/telegram/telegram.service.ts
diff --git a/src/integrations/telegram/telegram.update.ts b/apps/production/src/integrations/telegram/telegram.update.ts
similarity index 100%
rename from src/integrations/telegram/telegram.update.ts
rename to apps/production/src/integrations/telegram/telegram.update.ts
diff --git a/selfhosted-src/logger/logger.module.ts b/apps/production/src/logger/logger.module.ts
similarity index 100%
rename from selfhosted-src/logger/logger.module.ts
rename to apps/production/src/logger/logger.module.ts
diff --git a/src/logger/logger.service.spec.ts b/apps/production/src/logger/logger.service.spec.ts
similarity index 100%
rename from src/logger/logger.service.spec.ts
rename to apps/production/src/logger/logger.service.spec.ts
diff --git a/selfhosted-src/logger/logger.service.ts b/apps/production/src/logger/logger.service.ts
similarity index 100%
rename from selfhosted-src/logger/logger.service.ts
rename to apps/production/src/logger/logger.service.ts
diff --git a/src/mailer/letter.ts b/apps/production/src/mailer/letter.ts
similarity index 100%
rename from src/mailer/letter.ts
rename to apps/production/src/mailer/letter.ts
diff --git a/src/mailer/mailer.module.ts b/apps/production/src/mailer/mailer.module.ts
similarity index 100%
rename from src/mailer/mailer.module.ts
rename to apps/production/src/mailer/mailer.module.ts
diff --git a/src/mailer/mailer.service.spec.ts b/apps/production/src/mailer/mailer.service.spec.ts
similarity index 100%
rename from src/mailer/mailer.service.spec.ts
rename to apps/production/src/mailer/mailer.service.spec.ts
diff --git a/src/mailer/mailer.service.ts b/apps/production/src/mailer/mailer.service.ts
similarity index 100%
rename from src/mailer/mailer.service.ts
rename to apps/production/src/mailer/mailer.service.ts
diff --git a/src/main.ts b/apps/production/src/main.ts
similarity index 100%
rename from src/main.ts
rename to apps/production/src/main.ts
diff --git a/src/marketplace/categories/categories.controller.spec.ts b/apps/production/src/marketplace/categories/categories.controller.spec.ts
similarity index 100%
rename from src/marketplace/categories/categories.controller.spec.ts
rename to apps/production/src/marketplace/categories/categories.controller.spec.ts
diff --git a/src/marketplace/categories/categories.controller.ts b/apps/production/src/marketplace/categories/categories.controller.ts
similarity index 100%
rename from src/marketplace/categories/categories.controller.ts
rename to apps/production/src/marketplace/categories/categories.controller.ts
diff --git a/src/marketplace/categories/categories.module.ts b/apps/production/src/marketplace/categories/categories.module.ts
similarity index 100%
rename from src/marketplace/categories/categories.module.ts
rename to apps/production/src/marketplace/categories/categories.module.ts
diff --git a/src/marketplace/categories/categories.service.spec.ts b/apps/production/src/marketplace/categories/categories.service.spec.ts
similarity index 100%
rename from src/marketplace/categories/categories.service.spec.ts
rename to apps/production/src/marketplace/categories/categories.service.spec.ts
diff --git a/src/marketplace/categories/categories.service.ts b/apps/production/src/marketplace/categories/categories.service.ts
similarity index 100%
rename from src/marketplace/categories/categories.service.ts
rename to apps/production/src/marketplace/categories/categories.service.ts
diff --git a/src/marketplace/categories/category.entity.ts b/apps/production/src/marketplace/categories/category.entity.ts
similarity index 100%
rename from src/marketplace/categories/category.entity.ts
rename to apps/production/src/marketplace/categories/category.entity.ts
diff --git a/src/marketplace/categories/dtos/create-category.dto.ts b/apps/production/src/marketplace/categories/dtos/create-category.dto.ts
similarity index 100%
rename from src/marketplace/categories/dtos/create-category.dto.ts
rename to apps/production/src/marketplace/categories/dtos/create-category.dto.ts
diff --git a/src/marketplace/categories/dtos/delete-category-params.dto.ts b/apps/production/src/marketplace/categories/dtos/delete-category-params.dto.ts
similarity index 100%
rename from src/marketplace/categories/dtos/delete-category-params.dto.ts
rename to apps/production/src/marketplace/categories/dtos/delete-category-params.dto.ts
diff --git a/src/marketplace/categories/dtos/get-all-categories-queries.dto.ts b/apps/production/src/marketplace/categories/dtos/get-all-categories-queries.dto.ts
similarity index 100%
rename from src/marketplace/categories/dtos/get-all-categories-queries.dto.ts
rename to apps/production/src/marketplace/categories/dtos/get-all-categories-queries.dto.ts
diff --git a/src/marketplace/categories/dtos/get-category-params.dto.ts b/apps/production/src/marketplace/categories/dtos/get-category-params.dto.ts
similarity index 100%
rename from src/marketplace/categories/dtos/get-category-params.dto.ts
rename to apps/production/src/marketplace/categories/dtos/get-category-params.dto.ts
diff --git a/src/marketplace/categories/dtos/update-category-params.dto.ts b/apps/production/src/marketplace/categories/dtos/update-category-params.dto.ts
similarity index 100%
rename from src/marketplace/categories/dtos/update-category-params.dto.ts
rename to apps/production/src/marketplace/categories/dtos/update-category-params.dto.ts
diff --git a/src/marketplace/categories/dtos/update-category.dto.ts b/apps/production/src/marketplace/categories/dtos/update-category.dto.ts
similarity index 100%
rename from src/marketplace/categories/dtos/update-category.dto.ts
rename to apps/production/src/marketplace/categories/dtos/update-category.dto.ts
diff --git a/src/marketplace/categories/interfaces/create-category.interface.ts b/apps/production/src/marketplace/categories/interfaces/create-category.interface.ts
similarity index 100%
rename from src/marketplace/categories/interfaces/create-category.interface.ts
rename to apps/production/src/marketplace/categories/interfaces/create-category.interface.ts
diff --git a/src/marketplace/categories/interfaces/save-category.interface.ts b/apps/production/src/marketplace/categories/interfaces/save-category.interface.ts
similarity index 100%
rename from src/marketplace/categories/interfaces/save-category.interface.ts
rename to apps/production/src/marketplace/categories/interfaces/save-category.interface.ts
diff --git a/src/marketplace/categories/interfaces/update-category.interface.ts b/apps/production/src/marketplace/categories/interfaces/update-category.interface.ts
similarity index 100%
rename from src/marketplace/categories/interfaces/update-category.interface.ts
rename to apps/production/src/marketplace/categories/interfaces/update-category.interface.ts
diff --git a/src/marketplace/cdn/cdn.module.ts b/apps/production/src/marketplace/cdn/cdn.module.ts
similarity index 100%
rename from src/marketplace/cdn/cdn.module.ts
rename to apps/production/src/marketplace/cdn/cdn.module.ts
diff --git a/src/marketplace/cdn/cdn.service.spec.ts b/apps/production/src/marketplace/cdn/cdn.service.spec.ts
similarity index 100%
rename from src/marketplace/cdn/cdn.service.spec.ts
rename to apps/production/src/marketplace/cdn/cdn.service.spec.ts
diff --git a/src/marketplace/cdn/cdn.service.ts b/apps/production/src/marketplace/cdn/cdn.service.ts
similarity index 100%
rename from src/marketplace/cdn/cdn.service.ts
rename to apps/production/src/marketplace/cdn/cdn.service.ts
diff --git a/src/marketplace/comments/comments.controller.spec.ts b/apps/production/src/marketplace/comments/comments.controller.spec.ts
similarity index 100%
rename from src/marketplace/comments/comments.controller.spec.ts
rename to apps/production/src/marketplace/comments/comments.controller.spec.ts
diff --git a/src/marketplace/comments/comments.controller.ts b/apps/production/src/marketplace/comments/comments.controller.ts
similarity index 100%
rename from src/marketplace/comments/comments.controller.ts
rename to apps/production/src/marketplace/comments/comments.controller.ts
diff --git a/src/marketplace/comments/comments.module.ts b/apps/production/src/marketplace/comments/comments.module.ts
similarity index 100%
rename from src/marketplace/comments/comments.module.ts
rename to apps/production/src/marketplace/comments/comments.module.ts
diff --git a/src/marketplace/comments/comments.service.spec.ts b/apps/production/src/marketplace/comments/comments.service.spec.ts
similarity index 100%
rename from src/marketplace/comments/comments.service.spec.ts
rename to apps/production/src/marketplace/comments/comments.service.spec.ts
diff --git a/src/marketplace/comments/comments.service.ts b/apps/production/src/marketplace/comments/comments.service.ts
similarity index 100%
rename from src/marketplace/comments/comments.service.ts
rename to apps/production/src/marketplace/comments/comments.service.ts
diff --git a/src/marketplace/comments/dtos/bodies/create-comment.dto.ts b/apps/production/src/marketplace/comments/dtos/bodies/create-comment.dto.ts
similarity index 100%
rename from src/marketplace/comments/dtos/bodies/create-comment.dto.ts
rename to apps/production/src/marketplace/comments/dtos/bodies/create-comment.dto.ts
diff --git a/src/marketplace/comments/dtos/params/delete-comment.dto.ts b/apps/production/src/marketplace/comments/dtos/params/delete-comment.dto.ts
similarity index 100%
rename from src/marketplace/comments/dtos/params/delete-comment.dto.ts
rename to apps/production/src/marketplace/comments/dtos/params/delete-comment.dto.ts
diff --git a/src/marketplace/comments/dtos/params/get-comment.dto.ts b/apps/production/src/marketplace/comments/dtos/params/get-comment.dto.ts
similarity index 100%
rename from src/marketplace/comments/dtos/params/get-comment.dto.ts
rename to apps/production/src/marketplace/comments/dtos/params/get-comment.dto.ts
diff --git a/src/marketplace/comments/dtos/queries/create-comment.dto.ts b/apps/production/src/marketplace/comments/dtos/queries/create-comment.dto.ts
similarity index 100%
rename from src/marketplace/comments/dtos/queries/create-comment.dto.ts
rename to apps/production/src/marketplace/comments/dtos/queries/create-comment.dto.ts
diff --git a/src/marketplace/comments/dtos/queries/get-comments.dto.ts b/apps/production/src/marketplace/comments/dtos/queries/get-comments.dto.ts
similarity index 100%
rename from src/marketplace/comments/dtos/queries/get-comments.dto.ts
rename to apps/production/src/marketplace/comments/dtos/queries/get-comments.dto.ts
diff --git a/src/marketplace/comments/entities/comment.entity.ts b/apps/production/src/marketplace/comments/entities/comment.entity.ts
similarity index 100%
rename from src/marketplace/comments/entities/comment.entity.ts
rename to apps/production/src/marketplace/comments/entities/comment.entity.ts
diff --git a/src/marketplace/common/pipes/body-validation.pipe.ts b/apps/production/src/marketplace/common/pipes/body-validation.pipe.ts
similarity index 100%
rename from src/marketplace/common/pipes/body-validation.pipe.ts
rename to apps/production/src/marketplace/common/pipes/body-validation.pipe.ts
diff --git a/src/marketplace/complaints/complaints.controller.spec.ts b/apps/production/src/marketplace/complaints/complaints.controller.spec.ts
similarity index 100%
rename from src/marketplace/complaints/complaints.controller.spec.ts
rename to apps/production/src/marketplace/complaints/complaints.controller.spec.ts
diff --git a/src/marketplace/complaints/complaints.controller.ts b/apps/production/src/marketplace/complaints/complaints.controller.ts
similarity index 100%
rename from src/marketplace/complaints/complaints.controller.ts
rename to apps/production/src/marketplace/complaints/complaints.controller.ts
diff --git a/src/marketplace/complaints/complaints.module.ts b/apps/production/src/marketplace/complaints/complaints.module.ts
similarity index 100%
rename from src/marketplace/complaints/complaints.module.ts
rename to apps/production/src/marketplace/complaints/complaints.module.ts
diff --git a/src/marketplace/complaints/complaints.service.spec.ts b/apps/production/src/marketplace/complaints/complaints.service.spec.ts
similarity index 100%
rename from src/marketplace/complaints/complaints.service.spec.ts
rename to apps/production/src/marketplace/complaints/complaints.service.spec.ts
diff --git a/src/marketplace/complaints/complaints.service.ts b/apps/production/src/marketplace/complaints/complaints.service.ts
similarity index 100%
rename from src/marketplace/complaints/complaints.service.ts
rename to apps/production/src/marketplace/complaints/complaints.service.ts
diff --git a/src/marketplace/complaints/dtos/bodies/create-complaint.dto.ts b/apps/production/src/marketplace/complaints/dtos/bodies/create-complaint.dto.ts
similarity index 100%
rename from src/marketplace/complaints/dtos/bodies/create-complaint.dto.ts
rename to apps/production/src/marketplace/complaints/dtos/bodies/create-complaint.dto.ts
diff --git a/src/marketplace/complaints/dtos/bodies/resolve-complaint.dto.ts b/apps/production/src/marketplace/complaints/dtos/bodies/resolve-complaint.dto.ts
similarity index 100%
rename from src/marketplace/complaints/dtos/bodies/resolve-complaint.dto.ts
rename to apps/production/src/marketplace/complaints/dtos/bodies/resolve-complaint.dto.ts
diff --git a/src/marketplace/complaints/dtos/params/get-complaint.dto.ts b/apps/production/src/marketplace/complaints/dtos/params/get-complaint.dto.ts
similarity index 100%
rename from src/marketplace/complaints/dtos/params/get-complaint.dto.ts
rename to apps/production/src/marketplace/complaints/dtos/params/get-complaint.dto.ts
diff --git a/src/marketplace/complaints/dtos/params/resolve-complaint.dto.ts b/apps/production/src/marketplace/complaints/dtos/params/resolve-complaint.dto.ts
similarity index 100%
rename from src/marketplace/complaints/dtos/params/resolve-complaint.dto.ts
rename to apps/production/src/marketplace/complaints/dtos/params/resolve-complaint.dto.ts
diff --git a/src/marketplace/complaints/dtos/queries/create-complaint.dto.ts b/apps/production/src/marketplace/complaints/dtos/queries/create-complaint.dto.ts
similarity index 100%
rename from src/marketplace/complaints/dtos/queries/create-complaint.dto.ts
rename to apps/production/src/marketplace/complaints/dtos/queries/create-complaint.dto.ts
diff --git a/src/marketplace/complaints/dtos/queries/get-complaints.dto.ts b/apps/production/src/marketplace/complaints/dtos/queries/get-complaints.dto.ts
similarity index 100%
rename from src/marketplace/complaints/dtos/queries/get-complaints.dto.ts
rename to apps/production/src/marketplace/complaints/dtos/queries/get-complaints.dto.ts
diff --git a/src/marketplace/complaints/entities/complaint.entity.ts b/apps/production/src/marketplace/complaints/entities/complaint.entity.ts
similarity index 100%
rename from src/marketplace/complaints/entities/complaint.entity.ts
rename to apps/production/src/marketplace/complaints/entities/complaint.entity.ts
diff --git a/src/marketplace/complaints/enums/complaint-status.enum.ts b/apps/production/src/marketplace/complaints/enums/complaint-status.enum.ts
similarity index 100%
rename from src/marketplace/complaints/enums/complaint-status.enum.ts
rename to apps/production/src/marketplace/complaints/enums/complaint-status.enum.ts
diff --git a/src/marketplace/extensions/dtos/bodies/install-extension.dto.ts b/apps/production/src/marketplace/extensions/dtos/bodies/install-extension.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/bodies/install-extension.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/bodies/install-extension.dto.ts
diff --git a/src/marketplace/extensions/dtos/bodies/uninstall-extension.dto.ts b/apps/production/src/marketplace/extensions/dtos/bodies/uninstall-extension.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/bodies/uninstall-extension.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/bodies/uninstall-extension.dto.ts
diff --git a/src/marketplace/extensions/dtos/create-extension.dto.ts b/apps/production/src/marketplace/extensions/dtos/create-extension.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/create-extension.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/create-extension.dto.ts
diff --git a/src/marketplace/extensions/dtos/delete-extension-params.dto.ts b/apps/production/src/marketplace/extensions/dtos/delete-extension-params.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/delete-extension-params.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/delete-extension-params.dto.ts
diff --git a/src/marketplace/extensions/dtos/get-all-extensions-queries.dto.ts b/apps/production/src/marketplace/extensions/dtos/get-all-extensions-queries.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/get-all-extensions-queries.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/get-all-extensions-queries.dto.ts
diff --git a/src/marketplace/extensions/dtos/get-extension-params.dto.ts b/apps/production/src/marketplace/extensions/dtos/get-extension-params.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/get-extension-params.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/get-extension-params.dto.ts
diff --git a/src/marketplace/extensions/dtos/index.ts b/apps/production/src/marketplace/extensions/dtos/index.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/index.ts
rename to apps/production/src/marketplace/extensions/dtos/index.ts
diff --git a/src/marketplace/extensions/dtos/params/install-extension.dto.ts b/apps/production/src/marketplace/extensions/dtos/params/install-extension.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/params/install-extension.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/params/install-extension.dto.ts
diff --git a/src/marketplace/extensions/dtos/params/uninstall-extension.dto.ts b/apps/production/src/marketplace/extensions/dtos/params/uninstall-extension.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/params/uninstall-extension.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/params/uninstall-extension.dto.ts
diff --git a/src/marketplace/extensions/dtos/queries/get-installed-extensions.dto.ts b/apps/production/src/marketplace/extensions/dtos/queries/get-installed-extensions.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/queries/get-installed-extensions.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/queries/get-installed-extensions.dto.ts
diff --git a/src/marketplace/extensions/dtos/search-extension-queries.dto.ts b/apps/production/src/marketplace/extensions/dtos/search-extension-queries.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/search-extension-queries.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/search-extension-queries.dto.ts
diff --git a/src/marketplace/extensions/dtos/update-extension-params.dto.ts b/apps/production/src/marketplace/extensions/dtos/update-extension-params.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/update-extension-params.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/update-extension-params.dto.ts
diff --git a/src/marketplace/extensions/dtos/update-extension.dto.ts b/apps/production/src/marketplace/extensions/dtos/update-extension.dto.ts
similarity index 100%
rename from src/marketplace/extensions/dtos/update-extension.dto.ts
rename to apps/production/src/marketplace/extensions/dtos/update-extension.dto.ts
diff --git a/src/marketplace/extensions/entities/extension-to-project.entity.ts b/apps/production/src/marketplace/extensions/entities/extension-to-project.entity.ts
similarity index 100%
rename from src/marketplace/extensions/entities/extension-to-project.entity.ts
rename to apps/production/src/marketplace/extensions/entities/extension-to-project.entity.ts
diff --git a/src/marketplace/extensions/entities/extension-to-user.entity.ts b/apps/production/src/marketplace/extensions/entities/extension-to-user.entity.ts
similarity index 100%
rename from src/marketplace/extensions/entities/extension-to-user.entity.ts
rename to apps/production/src/marketplace/extensions/entities/extension-to-user.entity.ts
diff --git a/src/marketplace/extensions/entities/extension.entity.ts b/apps/production/src/marketplace/extensions/entities/extension.entity.ts
similarity index 100%
rename from src/marketplace/extensions/entities/extension.entity.ts
rename to apps/production/src/marketplace/extensions/entities/extension.entity.ts
diff --git a/src/marketplace/extensions/enums/extension-status.enum.ts b/apps/production/src/marketplace/extensions/enums/extension-status.enum.ts
similarity index 100%
rename from src/marketplace/extensions/enums/extension-status.enum.ts
rename to apps/production/src/marketplace/extensions/enums/extension-status.enum.ts
diff --git a/src/marketplace/extensions/enums/sort-by-extension.enum.ts b/apps/production/src/marketplace/extensions/enums/sort-by-extension.enum.ts
similarity index 100%
rename from src/marketplace/extensions/enums/sort-by-extension.enum.ts
rename to apps/production/src/marketplace/extensions/enums/sort-by-extension.enum.ts
diff --git a/src/marketplace/extensions/extensions.controller.spec.ts b/apps/production/src/marketplace/extensions/extensions.controller.spec.ts
similarity index 100%
rename from src/marketplace/extensions/extensions.controller.spec.ts
rename to apps/production/src/marketplace/extensions/extensions.controller.spec.ts
diff --git a/src/marketplace/extensions/extensions.controller.ts b/apps/production/src/marketplace/extensions/extensions.controller.ts
similarity index 100%
rename from src/marketplace/extensions/extensions.controller.ts
rename to apps/production/src/marketplace/extensions/extensions.controller.ts
diff --git a/src/marketplace/extensions/extensions.module.ts b/apps/production/src/marketplace/extensions/extensions.module.ts
similarity index 100%
rename from src/marketplace/extensions/extensions.module.ts
rename to apps/production/src/marketplace/extensions/extensions.module.ts
diff --git a/src/marketplace/extensions/extensions.service.spec.ts b/apps/production/src/marketplace/extensions/extensions.service.spec.ts
similarity index 100%
rename from src/marketplace/extensions/extensions.service.spec.ts
rename to apps/production/src/marketplace/extensions/extensions.service.spec.ts
diff --git a/src/marketplace/extensions/extensions.service.ts b/apps/production/src/marketplace/extensions/extensions.service.ts
similarity index 100%
rename from src/marketplace/extensions/extensions.service.ts
rename to apps/production/src/marketplace/extensions/extensions.service.ts
diff --git a/src/marketplace/extensions/interfaces/create-extension.interface.ts b/apps/production/src/marketplace/extensions/interfaces/create-extension.interface.ts
similarity index 100%
rename from src/marketplace/extensions/interfaces/create-extension.interface.ts
rename to apps/production/src/marketplace/extensions/interfaces/create-extension.interface.ts
diff --git a/src/marketplace/extensions/interfaces/index.ts b/apps/production/src/marketplace/extensions/interfaces/index.ts
similarity index 100%
rename from src/marketplace/extensions/interfaces/index.ts
rename to apps/production/src/marketplace/extensions/interfaces/index.ts
diff --git a/src/marketplace/extensions/interfaces/save-extension.interface.ts b/apps/production/src/marketplace/extensions/interfaces/save-extension.interface.ts
similarity index 100%
rename from src/marketplace/extensions/interfaces/save-extension.interface.ts
rename to apps/production/src/marketplace/extensions/interfaces/save-extension.interface.ts
diff --git a/src/marketplace/extensions/interfaces/update-extension.interface.ts b/apps/production/src/marketplace/extensions/interfaces/update-extension.interface.ts
similarity index 100%
rename from src/marketplace/extensions/interfaces/update-extension.interface.ts
rename to apps/production/src/marketplace/extensions/interfaces/update-extension.interface.ts
diff --git a/src/marketplace/extensions/interfaces/version-types.interface.ts b/apps/production/src/marketplace/extensions/interfaces/version-types.interface.ts
similarity index 100%
rename from src/marketplace/extensions/interfaces/version-types.interface.ts
rename to apps/production/src/marketplace/extensions/interfaces/version-types.interface.ts
diff --git a/src/marketplace/extensions/types/create-extension.type.ts b/apps/production/src/marketplace/extensions/types/create-extension.type.ts
similarity index 100%
rename from src/marketplace/extensions/types/create-extension.type.ts
rename to apps/production/src/marketplace/extensions/types/create-extension.type.ts
diff --git a/src/marketplace/extensions/types/index.ts b/apps/production/src/marketplace/extensions/types/index.ts
similarity index 100%
rename from src/marketplace/extensions/types/index.ts
rename to apps/production/src/marketplace/extensions/types/index.ts
diff --git a/src/marketplace/extensions/types/update-extension.type.ts b/apps/production/src/marketplace/extensions/types/update-extension.type.ts
similarity index 100%
rename from src/marketplace/extensions/types/update-extension.type.ts
rename to apps/production/src/marketplace/extensions/types/update-extension.type.ts
diff --git a/src/marketplace/marketplace.module.ts b/apps/production/src/marketplace/marketplace.module.ts
similarity index 100%
rename from src/marketplace/marketplace.module.ts
rename to apps/production/src/marketplace/marketplace.module.ts
diff --git a/src/newrelic.ts b/apps/production/src/newrelic.ts
similarity index 100%
rename from src/newrelic.ts
rename to apps/production/src/newrelic.ts
diff --git a/src/ping/ping.controller.spec.ts b/apps/production/src/ping/ping.controller.spec.ts
similarity index 100%
rename from src/ping/ping.controller.spec.ts
rename to apps/production/src/ping/ping.controller.spec.ts
diff --git a/selfhosted-src/ping/ping.controller.ts b/apps/production/src/ping/ping.controller.ts
similarity index 100%
rename from selfhosted-src/ping/ping.controller.ts
rename to apps/production/src/ping/ping.controller.ts
diff --git a/selfhosted-src/ping/ping.module.ts b/apps/production/src/ping/ping.module.ts
similarity index 100%
rename from selfhosted-src/ping/ping.module.ts
rename to apps/production/src/ping/ping.module.ts
diff --git a/src/project/dto/add-subscriber.dto.ts b/apps/production/src/project/dto/add-subscriber.dto.ts
similarity index 100%
rename from src/project/dto/add-subscriber.dto.ts
rename to apps/production/src/project/dto/add-subscriber.dto.ts
diff --git a/src/project/dto/cancel-transfer-project.dto.ts b/apps/production/src/project/dto/cancel-transfer-project.dto.ts
similarity index 100%
rename from src/project/dto/cancel-transfer-project.dto.ts
rename to apps/production/src/project/dto/cancel-transfer-project.dto.ts
diff --git a/src/project/dto/confirm-subscriber-invite.dto.ts b/apps/production/src/project/dto/confirm-subscriber-invite.dto.ts
similarity index 100%
rename from src/project/dto/confirm-subscriber-invite.dto.ts
rename to apps/production/src/project/dto/confirm-subscriber-invite.dto.ts
diff --git a/src/project/dto/confirm-transfer-project.dto.ts b/apps/production/src/project/dto/confirm-transfer-project.dto.ts
similarity index 100%
rename from src/project/dto/confirm-transfer-project.dto.ts
rename to apps/production/src/project/dto/confirm-transfer-project.dto.ts
diff --git a/src/project/dto/get-subscribers.dto.ts b/apps/production/src/project/dto/get-subscribers.dto.ts
similarity index 100%
rename from src/project/dto/get-subscribers.dto.ts
rename to apps/production/src/project/dto/get-subscribers.dto.ts
diff --git a/src/project/dto/index.ts b/apps/production/src/project/dto/index.ts
similarity index 100%
rename from src/project/dto/index.ts
rename to apps/production/src/project/dto/index.ts
diff --git a/selfhosted-src/project/dto/project.dto.ts b/apps/production/src/project/dto/project.dto.ts
similarity index 100%
rename from selfhosted-src/project/dto/project.dto.ts
rename to apps/production/src/project/dto/project.dto.ts
diff --git a/src/project/dto/remove-subscriber.dto.ts b/apps/production/src/project/dto/remove-subscriber.dto.ts
similarity index 100%
rename from src/project/dto/remove-subscriber.dto.ts
rename to apps/production/src/project/dto/remove-subscriber.dto.ts
diff --git a/src/project/dto/share-update.dto.ts b/apps/production/src/project/dto/share-update.dto.ts
similarity index 100%
rename from src/project/dto/share-update.dto.ts
rename to apps/production/src/project/dto/share-update.dto.ts
diff --git a/src/project/dto/share.dto.ts b/apps/production/src/project/dto/share.dto.ts
similarity index 100%
rename from src/project/dto/share.dto.ts
rename to apps/production/src/project/dto/share.dto.ts
diff --git a/src/project/dto/transfer-project.dto.ts b/apps/production/src/project/dto/transfer-project.dto.ts
similarity index 100%
rename from src/project/dto/transfer-project.dto.ts
rename to apps/production/src/project/dto/transfer-project.dto.ts
diff --git a/src/project/dto/update-subscriber.dto.ts b/apps/production/src/project/dto/update-subscriber.dto.ts
similarity index 100%
rename from src/project/dto/update-subscriber.dto.ts
rename to apps/production/src/project/dto/update-subscriber.dto.ts
diff --git a/src/project/entity/index.ts b/apps/production/src/project/entity/index.ts
similarity index 100%
rename from src/project/entity/index.ts
rename to apps/production/src/project/entity/index.ts
diff --git a/src/project/entity/project-share.entity.ts b/apps/production/src/project/entity/project-share.entity.ts
similarity index 100%
rename from src/project/entity/project-share.entity.ts
rename to apps/production/src/project/entity/project-share.entity.ts
diff --git a/src/project/entity/project-subscriber.entity.ts b/apps/production/src/project/entity/project-subscriber.entity.ts
similarity index 100%
rename from src/project/entity/project-subscriber.entity.ts
rename to apps/production/src/project/entity/project-subscriber.entity.ts
diff --git a/src/project/entity/project.entity.ts b/apps/production/src/project/entity/project.entity.ts
similarity index 100%
rename from src/project/entity/project.entity.ts
rename to apps/production/src/project/entity/project.entity.ts
diff --git a/src/project/enums/index.ts b/apps/production/src/project/enums/index.ts
similarity index 100%
rename from src/project/enums/index.ts
rename to apps/production/src/project/enums/index.ts
diff --git a/src/project/enums/report-frequency.enum.ts b/apps/production/src/project/enums/report-frequency.enum.ts
similarity index 100%
rename from src/project/enums/report-frequency.enum.ts
rename to apps/production/src/project/enums/report-frequency.enum.ts
diff --git a/src/project/project.controller.spec.ts b/apps/production/src/project/project.controller.spec.ts
similarity index 100%
rename from src/project/project.controller.spec.ts
rename to apps/production/src/project/project.controller.spec.ts
diff --git a/src/project/project.controller.ts b/apps/production/src/project/project.controller.ts
similarity index 91%
rename from src/project/project.controller.ts
rename to apps/production/src/project/project.controller.ts
index 77a4c596b..3bd90bab2 100644
--- a/src/project/project.controller.ts
+++ b/apps/production/src/project/project.controller.ts
@@ -61,9 +61,7 @@ import {
isDevelopment,
PRODUCTION_ORIGIN,
} from '../common/constants'
-import {
- generateRandomString,
-} from '../common/utils'
+import { generateRandomString } from '../common/utils'
import {
AddSubscriberParamsDto,
AddSubscriberBodyDto,
@@ -382,32 +380,32 @@ export class ProjectController {
)
}
- const user = await this.userService.findOne(uid)
- const project = await this.projectService.findOneWhere(
- { id },
- {
- relations: ['admin'],
- select: ['id'],
- },
- )
+ const user = await this.userService.findOne(uid)
+ const project = await this.projectService.findOneWhere(
+ { id },
+ {
+ relations: ['admin'],
+ select: ['id'],
+ },
+ )
- if (_isEmpty(project)) {
- throw new NotFoundException(`Project with ID ${id} does not exist`)
- }
+ if (_isEmpty(project)) {
+ throw new NotFoundException(`Project with ID ${id} does not exist`)
+ }
- this.projectService.allowedToManage(project, uid, user.roles)
+ this.projectService.allowedToManage(project, uid, user.roles)
- const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`
- const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`
+ const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`
+ const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`
- try {
- await clickhouse.query(query1).toPromise()
- await clickhouse.query(query2).toPromise()
- return 'Project resetted successfully'
- } catch (e) {
- this.logger.error(e)
- return 'Error while resetting your project'
- }
+ try {
+ await clickhouse.query(query1).toPromise()
+ await clickhouse.query(query2).toPromise()
+ return 'Project resetted successfully'
+ } catch (e) {
+ this.logger.error(e)
+ return 'Error while resetting your project'
+ }
}
@Delete('/captcha/reset/:id')
@@ -584,14 +582,14 @@ export class ProjectController {
}
const project = await this.projectService.findOne(pid, {
- relations: ['admin', 'share'],
- })
+ relations: ['admin', 'share'],
+ })
- if (!project) {
- throw new NotFoundException('Project not found')
- }
+ if (!project) {
+ throw new NotFoundException('Project not found')
+ }
- this.projectService.allowedToManage(project, uid)
+ this.projectService.allowedToManage(project, uid)
from = dayjs(from).format('YYYY-MM-DD')
to = dayjs(to).format('YYYY-MM-DD 23:59:59')
@@ -1089,48 +1087,48 @@ export class ProjectController {
'The provided Project ID (pid) is incorrect',
)
}
- const user = await this.userService.findOne(uid)
- const project = await this.projectService.findOneWhere(
- { id },
- {
- relations: ['admin'],
- select: ['id'],
- },
- )
+ const user = await this.userService.findOne(uid)
+ const project = await this.projectService.findOneWhere(
+ { id },
+ {
+ relations: ['admin'],
+ select: ['id'],
+ },
+ )
- if (_isEmpty(project)) {
- throw new NotFoundException(`Project with ID ${id} does not exist`)
- }
+ if (_isEmpty(project)) {
+ throw new NotFoundException(`Project with ID ${id} does not exist`)
+ }
- this.projectService.allowedToManage(project, uid, user.roles)
+ this.projectService.allowedToManage(project, uid, user.roles)
- const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`
- const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`
+ const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`
+ const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`
- try {
- await clickhouse.query(query1).toPromise()
- await clickhouse.query(query2).toPromise()
- await deleteProjectRedis(id)
- } catch (e) {
- this.logger.error(e)
- return 'Error while deleting your project'
- }
+ try {
+ await clickhouse.query(query1).toPromise()
+ await clickhouse.query(query2).toPromise()
+ await deleteProjectRedis(id)
+ } catch (e) {
+ this.logger.error(e)
+ return 'Error while deleting your project'
+ }
- try {
- if (project.isCaptchaProject) {
- project.isAnalyticsProject = false
- await this.projectService.update(id, project)
- } else {
- await this.projectService.deleteMultipleShare(`project = "${id}"`)
- await this.projectService.delete(id)
- await this.deleteCAPTCHA(id, uid)
- }
- } catch (e) {
- this.logger.error(e)
- return 'Error while deleting your project'
+ try {
+ if (project.isCaptchaProject) {
+ project.isAnalyticsProject = false
+ await this.projectService.update(id, project)
+ } else {
+ await this.projectService.deleteMultipleShare(`project = "${id}"`)
+ await this.projectService.delete(id)
+ await this.deleteCAPTCHA(id, uid)
}
+ } catch (e) {
+ this.logger.error(e)
+ return 'Error while deleting your project'
+ }
- return 'Project deleted successfully'
+ return 'Project deleted successfully'
}
@Put('captcha/inherited/:id')
@@ -1200,23 +1198,23 @@ export class ProjectController {
this.logger.log({ projectDTO, uid, id }, 'PUT /project/:id')
this.projectService.validateProject(projectDTO)
const project = await this.projectService.findOne(id, {
- relations: ['admin', 'share', 'share.user'],
- })
- const user = await this.userService.findOne(uid)
+ relations: ['admin', 'share', 'share.user'],
+ })
+ const user = await this.userService.findOne(uid)
- if (_isEmpty(project)) {
- throw new NotFoundException()
- }
+ if (_isEmpty(project)) {
+ throw new NotFoundException()
+ }
- this.projectService.allowedToManage(project, uid, user.roles)
+ this.projectService.allowedToManage(project, uid, user.roles)
- project.active = projectDTO.active
- project.origins = _map(projectDTO.origins, _trim)
- project.ipBlacklist = _map(projectDTO.ipBlacklist, _trim)
- project.name = projectDTO.name
- project.public = projectDTO.public
+ project.active = projectDTO.active
+ project.origins = _map(projectDTO.origins, _trim)
+ project.ipBlacklist = _map(projectDTO.ipBlacklist, _trim)
+ project.name = projectDTO.name
+ project.public = projectDTO.public
- await this.projectService.update(id, _omit(project, ['share', 'admin']))
+ await this.projectService.update(id, _omit(project, ['share', 'admin']))
// await updateProjectRedis(id, project)
await deleteProjectRedis(id)
@@ -1278,8 +1276,8 @@ export class ProjectController {
}
const project = await this.projectService.findOne(id, {
- relations: ['admin'],
- })
+ relations: ['admin'],
+ })
if (_isEmpty(project)) {
throw new NotFoundException('Project was not found in the database')
diff --git a/src/project/project.module.ts b/apps/production/src/project/project.module.ts
similarity index 100%
rename from src/project/project.module.ts
rename to apps/production/src/project/project.module.ts
diff --git a/src/project/project.service.spec.ts b/apps/production/src/project/project.service.spec.ts
similarity index 100%
rename from src/project/project.service.spec.ts
rename to apps/production/src/project/project.service.spec.ts
diff --git a/src/project/project.service.ts b/apps/production/src/project/project.service.ts
similarity index 96%
rename from src/project/project.service.ts
rename to apps/production/src/project/project.service.ts
index 42645c94e..1f6c49dd8 100644
--- a/src/project/project.service.ts
+++ b/apps/production/src/project/project.service.ts
@@ -125,34 +125,34 @@ export class ProjectService {
let project: string | Project = await redis.get(pidKey)
if (_isEmpty(project)) {
- // todo: optimise the relations - select
- // select only required columns
- // https://stackoverflow.com/questions/59645009/how-to-return-only-some-columns-of-a-relations-with-typeorm
- project = await this.findOne(pid, {
- relations: ['admin'],
- select: [
- 'origins',
- 'active',
- 'admin',
- 'public',
- 'ipBlacklist',
- 'captchaSecretKey',
- 'isCaptchaEnabled',
- ],
- })
+ // todo: optimise the relations - select
+ // select only required columns
+ // https://stackoverflow.com/questions/59645009/how-to-return-only-some-columns-of-a-relations-with-typeorm
+ project = await this.findOne(pid, {
+ relations: ['admin'],
+ select: [
+ 'origins',
+ 'active',
+ 'admin',
+ 'public',
+ 'ipBlacklist',
+ 'captchaSecretKey',
+ 'isCaptchaEnabled',
+ ],
+ })
if (_isEmpty(project))
throw new BadRequestException(
'The provided Project ID (pid) is incorrect',
)
- const share = await this.findShare({
- where: {
- project: pid,
- },
- relations: ['user'],
- })
- // @ts-ignore
- project = { ...project, share }
+ const share = await this.findShare({
+ where: {
+ project: pid,
+ },
+ relations: ['user'],
+ })
+ // @ts-ignore
+ project = { ...project, share }
await redis.set(
pidKey,
diff --git a/src/project/types/add-subscriber.type.ts b/apps/production/src/project/types/add-subscriber.type.ts
similarity index 100%
rename from src/project/types/add-subscriber.type.ts
rename to apps/production/src/project/types/add-subscriber.type.ts
diff --git a/src/project/types/index.ts b/apps/production/src/project/types/index.ts
similarity index 100%
rename from src/project/types/index.ts
rename to apps/production/src/project/types/index.ts
diff --git a/src/task-manager/task-manager.module.ts b/apps/production/src/task-manager/task-manager.module.ts
similarity index 100%
rename from src/task-manager/task-manager.module.ts
rename to apps/production/src/task-manager/task-manager.module.ts
diff --git a/src/task-manager/task-manager.service.spec.ts b/apps/production/src/task-manager/task-manager.service.spec.ts
similarity index 100%
rename from src/task-manager/task-manager.service.spec.ts
rename to apps/production/src/task-manager/task-manager.service.spec.ts
diff --git a/src/task-manager/task-manager.service.ts b/apps/production/src/task-manager/task-manager.service.ts
similarity index 99%
rename from src/task-manager/task-manager.service.ts
rename to apps/production/src/task-manager/task-manager.service.ts
index 5dfa0722c..699e1d645 100644
--- a/src/task-manager/task-manager.service.ts
+++ b/apps/production/src/task-manager/task-manager.service.ts
@@ -13,7 +13,11 @@ import * as _now from 'lodash/now'
import * as _find from 'lodash/find'
import { AlertService } from 'src/alert/alert.service'
-import { QueryCondition, QueryMetric, QueryTime } from 'src/alert/dto/alert.dto'
+import {
+ QueryCondition,
+ QueryMetric,
+ QueryTime,
+} from 'src/alert/dto/alert.dto'
import { ExtensionsService } from 'src/marketplace/extensions/extensions.service'
import { Extension } from 'src/marketplace/extensions/entities/extension.entity'
import { ReportFrequency } from 'src/project/enums'
diff --git a/src/twoFactorAuth/dto/2fa-auth.dto.ts b/apps/production/src/twoFactorAuth/dto/2fa-auth.dto.ts
similarity index 100%
rename from src/twoFactorAuth/dto/2fa-auth.dto.ts
rename to apps/production/src/twoFactorAuth/dto/2fa-auth.dto.ts
diff --git a/src/twoFactorAuth/twoFactorAuth,service.spec.ts b/apps/production/src/twoFactorAuth/twoFactorAuth,service.spec.ts
similarity index 100%
rename from src/twoFactorAuth/twoFactorAuth,service.spec.ts
rename to apps/production/src/twoFactorAuth/twoFactorAuth,service.spec.ts
diff --git a/src/twoFactorAuth/twoFactorAuth.controller.spec.ts b/apps/production/src/twoFactorAuth/twoFactorAuth.controller.spec.ts
similarity index 100%
rename from src/twoFactorAuth/twoFactorAuth.controller.spec.ts
rename to apps/production/src/twoFactorAuth/twoFactorAuth.controller.spec.ts
diff --git a/src/twoFactorAuth/twoFactorAuth.controller.ts b/apps/production/src/twoFactorAuth/twoFactorAuth.controller.ts
similarity index 100%
rename from src/twoFactorAuth/twoFactorAuth.controller.ts
rename to apps/production/src/twoFactorAuth/twoFactorAuth.controller.ts
diff --git a/src/twoFactorAuth/twoFactorAuth.module.ts b/apps/production/src/twoFactorAuth/twoFactorAuth.module.ts
similarity index 100%
rename from src/twoFactorAuth/twoFactorAuth.module.ts
rename to apps/production/src/twoFactorAuth/twoFactorAuth.module.ts
diff --git a/src/twoFactorAuth/twoFactorAuth.service.ts b/apps/production/src/twoFactorAuth/twoFactorAuth.service.ts
similarity index 100%
rename from src/twoFactorAuth/twoFactorAuth.service.ts
rename to apps/production/src/twoFactorAuth/twoFactorAuth.service.ts
diff --git a/src/user/dto/admin-update-user.dto.ts b/apps/production/src/user/dto/admin-update-user.dto.ts
similarity index 100%
rename from src/user/dto/admin-update-user.dto.ts
rename to apps/production/src/user/dto/admin-update-user.dto.ts
diff --git a/src/user/dto/update-user.dto.ts b/apps/production/src/user/dto/update-user.dto.ts
similarity index 100%
rename from src/user/dto/update-user.dto.ts
rename to apps/production/src/user/dto/update-user.dto.ts
diff --git a/src/user/dto/user-github.dto.ts b/apps/production/src/user/dto/user-github.dto.ts
similarity index 100%
rename from src/user/dto/user-github.dto.ts
rename to apps/production/src/user/dto/user-github.dto.ts
diff --git a/src/user/dto/user-google.dto.ts b/apps/production/src/user/dto/user-google.dto.ts
similarity index 100%
rename from src/user/dto/user-google.dto.ts
rename to apps/production/src/user/dto/user-google.dto.ts
diff --git a/src/user/dto/user.dto.ts b/apps/production/src/user/dto/user.dto.ts
similarity index 100%
rename from src/user/dto/user.dto.ts
rename to apps/production/src/user/dto/user.dto.ts
diff --git a/src/user/entities/refresh-token.entity.ts b/apps/production/src/user/entities/refresh-token.entity.ts
similarity index 100%
rename from src/user/entities/refresh-token.entity.ts
rename to apps/production/src/user/entities/refresh-token.entity.ts
diff --git a/src/user/entities/user.entity.ts b/apps/production/src/user/entities/user.entity.ts
similarity index 100%
rename from src/user/entities/user.entity.ts
rename to apps/production/src/user/entities/user.entity.ts
diff --git a/src/user/user.controller.spec.ts b/apps/production/src/user/user.controller.spec.ts
similarity index 100%
rename from src/user/user.controller.spec.ts
rename to apps/production/src/user/user.controller.spec.ts
diff --git a/src/user/user.controller.ts b/apps/production/src/user/user.controller.ts
similarity index 98%
rename from src/user/user.controller.ts
rename to apps/production/src/user/user.controller.ts
index 1309261a9..a4fbe881a 100644
--- a/src/user/user.controller.ts
+++ b/apps/production/src/user/user.controller.ts
@@ -87,17 +87,17 @@ export class UserController {
this.logger.log({ user_id }, 'GET /user/me')
let user
- const sharedProjects = await this.projectService.findShare({
- where: {
- user: user_id,
- },
- relations: ['project'],
- })
- user = this.userService.processUser(
- await this.userService.findOneWhere({ id: user_id }),
- )
+ const sharedProjects = await this.projectService.findShare({
+ where: {
+ user: user_id,
+ },
+ relations: ['project'],
+ })
+ user = this.userService.processUser(
+ await this.userService.findOneWhere({ id: user_id }),
+ )
- user.sharedProjects = sharedProjects
+ user.sharedProjects = sharedProjects
return this.userService.omitSensitiveData(user)
}
diff --git a/src/user/user.module.ts b/apps/production/src/user/user.module.ts
similarity index 100%
rename from src/user/user.module.ts
rename to apps/production/src/user/user.module.ts
diff --git a/src/user/user.service.spec.ts b/apps/production/src/user/user.service.spec.ts
similarity index 100%
rename from src/user/user.service.spec.ts
rename to apps/production/src/user/user.service.spec.ts
diff --git a/src/user/user.service.ts b/apps/production/src/user/user.service.ts
similarity index 100%
rename from src/user/user.service.ts
rename to apps/production/src/user/user.service.ts
diff --git a/src/webhook/webhook.controller.spec.ts b/apps/production/src/webhook/webhook.controller.spec.ts
similarity index 100%
rename from src/webhook/webhook.controller.spec.ts
rename to apps/production/src/webhook/webhook.controller.spec.ts
diff --git a/src/webhook/webhook.controller.ts b/apps/production/src/webhook/webhook.controller.ts
similarity index 100%
rename from src/webhook/webhook.controller.ts
rename to apps/production/src/webhook/webhook.controller.ts
diff --git a/src/webhook/webhook.module.ts b/apps/production/src/webhook/webhook.module.ts
similarity index 100%
rename from src/webhook/webhook.module.ts
rename to apps/production/src/webhook/webhook.module.ts
diff --git a/src/webhook/webhook.service.spec.ts b/apps/production/src/webhook/webhook.service.spec.ts
similarity index 100%
rename from src/webhook/webhook.service.spec.ts
rename to apps/production/src/webhook/webhook.service.spec.ts
diff --git a/src/webhook/webhook.service.ts b/apps/production/src/webhook/webhook.service.ts
similarity index 100%
rename from src/webhook/webhook.service.ts
rename to apps/production/src/webhook/webhook.service.ts
diff --git a/apps/production/tsconfig.app.json b/apps/production/tsconfig.app.json
new file mode 100644
index 000000000..d8e88dc36
--- /dev/null
+++ b/apps/production/tsconfig.app.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "declaration": true,
+ "removeComments": true,
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "allowSyntheticDefaultImports": true,
+ "target": "es2017",
+ "sourceMap": true,
+ "outDir": "./dist",
+ "baseUrl": "./",
+ "incremental": true,
+ "skipLibCheck": true
+ }
+}
diff --git a/selfhosted-src/analytics/analytics.controller.ts b/apps/selfhosted/src/analytics/analytics.controller.ts
similarity index 99%
rename from selfhosted-src/analytics/analytics.controller.ts
rename to apps/selfhosted/src/analytics/analytics.controller.ts
index a71997ed9..ea1d6ec4b 100644
--- a/selfhosted-src/analytics/analytics.controller.ts
+++ b/apps/selfhosted/src/analytics/analytics.controller.ts
@@ -29,8 +29,8 @@ import { ApiTags } from '@nestjs/swagger'
import * as UAParser from 'ua-parser-js'
import * as isbot from 'isbot'
-import { OptionalJwtAccessTokenGuard } from 'selfhosted-src/auth/guards'
-import { Auth, Public } from 'selfhosted-src/auth/decorators'
+import { OptionalJwtAccessTokenGuard } from 'src/auth/guards'
+import { Auth, Public } from 'src/auth/decorators'
import {
AnalyticsService,
getSessionKey,
diff --git a/src/analytics/analytics.module.ts b/apps/selfhosted/src/analytics/analytics.module.ts
similarity index 100%
rename from src/analytics/analytics.module.ts
rename to apps/selfhosted/src/analytics/analytics.module.ts
diff --git a/selfhosted-src/analytics/analytics.service.ts b/apps/selfhosted/src/analytics/analytics.service.ts
similarity index 99%
rename from selfhosted-src/analytics/analytics.service.ts
rename to apps/selfhosted/src/analytics/analytics.service.ts
index 8bb084a26..59096ed67 100644
--- a/selfhosted-src/analytics/analytics.service.ts
+++ b/apps/selfhosted/src/analytics/analytics.service.ts
@@ -27,9 +27,7 @@ import {
PreconditionFailedException,
} from '@nestjs/common'
-import {
- DEFAULT_TIMEZONE,
-} from '../user/entities/user.entity'
+import { DEFAULT_TIMEZONE } from '../user/entities/user.entity'
import {
redis,
isValidPID,
diff --git a/src/analytics/dto/events.dto.ts b/apps/selfhosted/src/analytics/dto/events.dto.ts
similarity index 100%
rename from src/analytics/dto/events.dto.ts
rename to apps/selfhosted/src/analytics/dto/events.dto.ts
diff --git a/src/analytics/dto/get-custom-events.dto.ts b/apps/selfhosted/src/analytics/dto/get-custom-events.dto.ts
similarity index 100%
rename from src/analytics/dto/get-custom-events.dto.ts
rename to apps/selfhosted/src/analytics/dto/get-custom-events.dto.ts
diff --git a/src/analytics/dto/getData.dto.ts b/apps/selfhosted/src/analytics/dto/getData.dto.ts
similarity index 100%
rename from src/analytics/dto/getData.dto.ts
rename to apps/selfhosted/src/analytics/dto/getData.dto.ts
diff --git a/src/analytics/dto/getUserFlow.dto.ts b/apps/selfhosted/src/analytics/dto/getUserFlow.dto.ts
similarity index 100%
rename from src/analytics/dto/getUserFlow.dto.ts
rename to apps/selfhosted/src/analytics/dto/getUserFlow.dto.ts
diff --git a/src/analytics/dto/pageviews.dto.ts b/apps/selfhosted/src/analytics/dto/pageviews.dto.ts
similarity index 100%
rename from src/analytics/dto/pageviews.dto.ts
rename to apps/selfhosted/src/analytics/dto/pageviews.dto.ts
diff --git a/src/analytics/interfaces/index.ts b/apps/selfhosted/src/analytics/interfaces/index.ts
similarity index 100%
rename from src/analytics/interfaces/index.ts
rename to apps/selfhosted/src/analytics/interfaces/index.ts
diff --git a/selfhosted-src/app.module.ts b/apps/selfhosted/src/app.module.ts
similarity index 100%
rename from selfhosted-src/app.module.ts
rename to apps/selfhosted/src/app.module.ts
diff --git a/selfhosted-src/auth/auth.controller.ts b/apps/selfhosted/src/auth/auth.controller.ts
similarity index 86%
rename from selfhosted-src/auth/auth.controller.ts
rename to apps/selfhosted/src/auth/auth.controller.ts
index dc6d3d89c..42d617a6a 100644
--- a/selfhosted-src/auth/auth.controller.ts
+++ b/apps/selfhosted/src/auth/auth.controller.ts
@@ -13,23 +13,14 @@ import {
UnauthorizedException,
Headers,
} from '@nestjs/common'
-import {
- ApiTags,
- ApiOperation,
- ApiOkResponse,
-} from '@nestjs/swagger'
+import { ApiTags, ApiOperation, ApiOkResponse } from '@nestjs/swagger'
import { I18nValidationExceptionFilter, I18n, I18nContext } from 'nestjs-i18n'
-import { checkRateLimit } from 'selfhosted-src/common/utils'
-import {
- generateSelfhostedUser,
-} from 'selfhosted-src/user/entities/user.entity'
+import { checkRateLimit } from 'src/common/utils'
+import { generateSelfhostedUser } from 'src/user/entities/user.entity'
import { AuthService } from './auth.service'
import { Public, CurrentUserId, CurrentUser } from './decorators'
-import {
- LoginResponseDto,
- LoginRequestDto,
-} from './dtos'
+import { LoginResponseDto, LoginRequestDto } from './dtos'
import { JwtAccessTokenGuard, JwtRefreshTokenGuard } from './guards'
@ApiTags('Auth')
@@ -45,9 +36,7 @@ import { JwtAccessTokenGuard, JwtRefreshTokenGuard } from './guards'
}),
)
export class AuthController {
- constructor(
- private readonly authService: AuthService,
- ) {}
+ constructor(private readonly authService: AuthService) {}
@ApiOperation({ summary: 'Login a user' })
@ApiOkResponse({
@@ -68,7 +57,7 @@ export class AuthController {
await checkRateLimit(ip, 'login', 10, 1800)
- let user = await this.authService.validateUser(body.email, body.password)
+ const user = await this.authService.validateUser(body.email, body.password)
if (!user) {
throw new ConflictException(i18n.t('auth.invalidCredentials'))
@@ -79,10 +68,10 @@ export class AuthController {
!user.isTwoFactorAuthenticationEnabled,
)
- return {
- ...jwtTokens,
- user,
- }
+ return {
+ ...jwtTokens,
+ user,
+ }
}
@ApiOperation({ summary: 'Refresh a token' })
diff --git a/selfhosted-src/auth/auth.module.ts b/apps/selfhosted/src/auth/auth.module.ts
similarity index 89%
rename from selfhosted-src/auth/auth.module.ts
rename to apps/selfhosted/src/auth/auth.module.ts
index 966cffd20..05e51b708 100644
--- a/selfhosted-src/auth/auth.module.ts
+++ b/apps/selfhosted/src/auth/auth.module.ts
@@ -10,10 +10,7 @@ import {
} from './strategies'
@Module({
- imports: [
- JwtModule.register({}),
- PassportModule,
- ],
+ imports: [JwtModule.register({}), PassportModule],
controllers: [AuthController],
providers: [
AuthService,
diff --git a/selfhosted-src/auth/auth.service.ts b/apps/selfhosted/src/auth/auth.service.ts
similarity index 82%
rename from selfhosted-src/auth/auth.service.ts
rename to apps/selfhosted/src/auth/auth.service.ts
index 0a986265d..5009c5442 100644
--- a/selfhosted-src/auth/auth.service.ts
+++ b/apps/selfhosted/src/auth/auth.service.ts
@@ -1,6 +1,4 @@
-import {
- Injectable,
-} from '@nestjs/common'
+import { Injectable } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { JwtService } from '@nestjs/jwt'
import { genSalt, hash } from 'bcrypt'
@@ -9,17 +7,17 @@ import * as _isEmpty from 'lodash/isEmpty'
import {
SelfhostedUser,
generateSelfhostedUser,
-} from 'selfhosted-src/user/entities/user.entity'
+} from 'src/user/entities/user.entity'
import {
saveRefreshTokenClickhouse,
findRefreshTokenClickhouse,
deleteRefreshTokenClickhouse,
-} from 'selfhosted-src/common/utils'
+} from 'src/common/utils'
import {
SELFHOSTED_EMAIL,
SELFHOSTED_PASSWORD,
JWT_ACCESS_TOKEN_SECRET,
-} from 'selfhosted-src/common/constants'
+} from 'src/common/constants'
@Injectable()
export class AuthService {
@@ -54,11 +52,11 @@ export class AuthService {
email: string,
password: string,
): Promise<SelfhostedUser | null> {
- if (email !== SELFHOSTED_EMAIL || password !== SELFHOSTED_PASSWORD) {
- return null
- }
+ if (email !== SELFHOSTED_EMAIL || password !== SELFHOSTED_PASSWORD) {
+ return null
+ }
- return generateSelfhostedUser()
+ return generateSelfhostedUser()
}
private async generateJwtRefreshToken(
@@ -77,7 +75,7 @@ export class AuthService {
},
)
- await saveRefreshTokenClickhouse(userId, refreshToken)
+ await saveRefreshTokenClickhouse(userId, refreshToken)
return refreshToken
}
@@ -86,8 +84,8 @@ export class AuthService {
userId: string,
refreshToken: string,
): Promise<boolean> {
- const tokens = await findRefreshTokenClickhouse(userId, refreshToken)
- return !_isEmpty(tokens)
+ const tokens = await findRefreshTokenClickhouse(userId, refreshToken)
+ return !_isEmpty(tokens)
}
public async generateJwtTokens(
diff --git a/selfhosted-src/auth/decorators/auth.decorator.ts b/apps/selfhosted/src/auth/decorators/auth.decorator.ts
similarity index 72%
rename from selfhosted-src/auth/decorators/auth.decorator.ts
rename to apps/selfhosted/src/auth/decorators/auth.decorator.ts
index c5491076b..25a30e4b9 100644
--- a/selfhosted-src/auth/decorators/auth.decorator.ts
+++ b/apps/selfhosted/src/auth/decorators/auth.decorator.ts
@@ -1,11 +1,10 @@
import { applyDecorators, SetMetadata, UseGuards } from '@nestjs/common'
import {
- ApiKeyRateLimitGuard,
JwtAccessTokenGuard,
MultiAuthGuard,
RolesGuard,
-} from 'selfhosted-src/auth/guards'
-import { UserType } from 'selfhosted-src/user/entities/user.entity'
+} from 'src/auth/guards'
+import { UserType } from 'src/user/entities/user.entity'
import { ROLES_KEY } from './roles.decorator'
export const IS_OPTIONAL_AUTH_KEY = 'isOptionalAuth'
@@ -18,7 +17,7 @@ export function Auth(
SetMetadata(ROLES_KEY, roles),
SetMetadata(IS_OPTIONAL_AUTH_KEY, isOptionalAuth),
isApiKeyAuth
- ? UseGuards(MultiAuthGuard, ApiKeyRateLimitGuard, RolesGuard)
+ ? UseGuards(MultiAuthGuard, RolesGuard)
: UseGuards(JwtAccessTokenGuard, RolesGuard),
)
}
diff --git a/src/auth/decorators/current-user-id.decorator.ts b/apps/selfhosted/src/auth/decorators/current-user-id.decorator.ts
similarity index 100%
rename from src/auth/decorators/current-user-id.decorator.ts
rename to apps/selfhosted/src/auth/decorators/current-user-id.decorator.ts
diff --git a/src/auth/decorators/current-user.decorator.ts b/apps/selfhosted/src/auth/decorators/current-user.decorator.ts
similarity index 100%
rename from src/auth/decorators/current-user.decorator.ts
rename to apps/selfhosted/src/auth/decorators/current-user.decorator.ts
diff --git a/src/auth/decorators/index.ts b/apps/selfhosted/src/auth/decorators/index.ts
similarity index 100%
rename from src/auth/decorators/index.ts
rename to apps/selfhosted/src/auth/decorators/index.ts
diff --git a/src/auth/decorators/public.decorator.ts b/apps/selfhosted/src/auth/decorators/public.decorator.ts
similarity index 100%
rename from src/auth/decorators/public.decorator.ts
rename to apps/selfhosted/src/auth/decorators/public.decorator.ts
diff --git a/selfhosted-src/auth/decorators/roles.decorator.ts b/apps/selfhosted/src/auth/decorators/roles.decorator.ts
similarity index 69%
rename from selfhosted-src/auth/decorators/roles.decorator.ts
rename to apps/selfhosted/src/auth/decorators/roles.decorator.ts
index fb70bbeb1..2a56336a4 100644
--- a/selfhosted-src/auth/decorators/roles.decorator.ts
+++ b/apps/selfhosted/src/auth/decorators/roles.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common'
-import { UserType } from 'selfhosted-src/user/entities/user.entity'
+import { UserType } from 'src/user/entities/user.entity'
export const ROLES_KEY = 'roles'
export const Roles = (...roles: UserType[]) => SetMetadata(ROLES_KEY, roles)
diff --git a/src/auth/decorators/two-fa-not-required.decorator.ts b/apps/selfhosted/src/auth/decorators/two-fa-not-required.decorator.ts
similarity index 100%
rename from src/auth/decorators/two-fa-not-required.decorator.ts
rename to apps/selfhosted/src/auth/decorators/two-fa-not-required.decorator.ts
diff --git a/src/auth/dtos/change-password.dto.ts b/apps/selfhosted/src/auth/dtos/change-password.dto.ts
similarity index 100%
rename from src/auth/dtos/change-password.dto.ts
rename to apps/selfhosted/src/auth/dtos/change-password.dto.ts
diff --git a/src/auth/dtos/confirm-change-email.dto.ts b/apps/selfhosted/src/auth/dtos/confirm-change-email.dto.ts
similarity index 100%
rename from src/auth/dtos/confirm-change-email.dto.ts
rename to apps/selfhosted/src/auth/dtos/confirm-change-email.dto.ts
diff --git a/src/auth/dtos/confirm-reset-password.dto.ts b/apps/selfhosted/src/auth/dtos/confirm-reset-password.dto.ts
similarity index 100%
rename from src/auth/dtos/confirm-reset-password.dto.ts
rename to apps/selfhosted/src/auth/dtos/confirm-reset-password.dto.ts
diff --git a/src/auth/dtos/index.ts b/apps/selfhosted/src/auth/dtos/index.ts
similarity index 100%
rename from src/auth/dtos/index.ts
rename to apps/selfhosted/src/auth/dtos/index.ts
diff --git a/src/auth/dtos/login.dto.ts b/apps/selfhosted/src/auth/dtos/login.dto.ts
similarity index 100%
rename from src/auth/dtos/login.dto.ts
rename to apps/selfhosted/src/auth/dtos/login.dto.ts
diff --git a/src/auth/dtos/process-sso-code.dto.ts b/apps/selfhosted/src/auth/dtos/process-sso-code.dto.ts
similarity index 100%
rename from src/auth/dtos/process-sso-code.dto.ts
rename to apps/selfhosted/src/auth/dtos/process-sso-code.dto.ts
diff --git a/src/auth/dtos/register.dto.ts b/apps/selfhosted/src/auth/dtos/register.dto.ts
similarity index 100%
rename from src/auth/dtos/register.dto.ts
rename to apps/selfhosted/src/auth/dtos/register.dto.ts
diff --git a/src/auth/dtos/request-change-email.dto.ts b/apps/selfhosted/src/auth/dtos/request-change-email.dto.ts
similarity index 100%
rename from src/auth/dtos/request-change-email.dto.ts
rename to apps/selfhosted/src/auth/dtos/request-change-email.dto.ts
diff --git a/src/auth/dtos/request-reset-password.dto.ts b/apps/selfhosted/src/auth/dtos/request-reset-password.dto.ts
similarity index 100%
rename from src/auth/dtos/request-reset-password.dto.ts
rename to apps/selfhosted/src/auth/dtos/request-reset-password.dto.ts
diff --git a/src/auth/dtos/reset-password.dto.ts b/apps/selfhosted/src/auth/dtos/reset-password.dto.ts
similarity index 100%
rename from src/auth/dtos/reset-password.dto.ts
rename to apps/selfhosted/src/auth/dtos/reset-password.dto.ts
diff --git a/src/auth/dtos/sso-generate.dto.ts b/apps/selfhosted/src/auth/dtos/sso-generate.dto.ts
similarity index 100%
rename from src/auth/dtos/sso-generate.dto.ts
rename to apps/selfhosted/src/auth/dtos/sso-generate.dto.ts
diff --git a/src/auth/dtos/sso-get-jwt-by-hash.dto.ts b/apps/selfhosted/src/auth/dtos/sso-get-jwt-by-hash.dto.ts
similarity index 100%
rename from src/auth/dtos/sso-get-jwt-by-hash.dto.ts
rename to apps/selfhosted/src/auth/dtos/sso-get-jwt-by-hash.dto.ts
diff --git a/src/auth/dtos/sso-link.dto.ts b/apps/selfhosted/src/auth/dtos/sso-link.dto.ts
similarity index 100%
rename from src/auth/dtos/sso-link.dto.ts
rename to apps/selfhosted/src/auth/dtos/sso-link.dto.ts
diff --git a/src/auth/dtos/sso-unlink.dto.ts b/apps/selfhosted/src/auth/dtos/sso-unlink.dto.ts
similarity index 100%
rename from src/auth/dtos/sso-unlink.dto.ts
rename to apps/selfhosted/src/auth/dtos/sso-unlink.dto.ts
diff --git a/src/auth/dtos/verify-email.dto.ts b/apps/selfhosted/src/auth/dtos/verify-email.dto.ts
similarity index 100%
rename from src/auth/dtos/verify-email.dto.ts
rename to apps/selfhosted/src/auth/dtos/verify-email.dto.ts
diff --git a/src/auth/guards/api-key.guard.ts b/apps/selfhosted/src/auth/guards/api-key.guard.ts
similarity index 100%
rename from src/auth/guards/api-key.guard.ts
rename to apps/selfhosted/src/auth/guards/api-key.guard.ts
diff --git a/src/auth/guards/index.ts b/apps/selfhosted/src/auth/guards/index.ts
similarity index 84%
rename from src/auth/guards/index.ts
rename to apps/selfhosted/src/auth/guards/index.ts
index 0658afa44..56b62f819 100644
--- a/src/auth/guards/index.ts
+++ b/apps/selfhosted/src/auth/guards/index.ts
@@ -3,5 +3,4 @@ export * from './jwt-refresh-token.guard'
export * from './roles.guard'
export * from './optional-jwt-access-token.guard'
export * from './api-key.guard'
-export * from './api-key-rate-limit.guard'
export * from './multi-auth.guard'
diff --git a/src/auth/guards/jwt-access-token.guard.ts b/apps/selfhosted/src/auth/guards/jwt-access-token.guard.ts
similarity index 100%
rename from src/auth/guards/jwt-access-token.guard.ts
rename to apps/selfhosted/src/auth/guards/jwt-access-token.guard.ts
diff --git a/src/auth/guards/jwt-refresh-token.guard.ts b/apps/selfhosted/src/auth/guards/jwt-refresh-token.guard.ts
similarity index 100%
rename from src/auth/guards/jwt-refresh-token.guard.ts
rename to apps/selfhosted/src/auth/guards/jwt-refresh-token.guard.ts
diff --git a/src/auth/guards/multi-auth.guard.ts b/apps/selfhosted/src/auth/guards/multi-auth.guard.ts
similarity index 100%
rename from src/auth/guards/multi-auth.guard.ts
rename to apps/selfhosted/src/auth/guards/multi-auth.guard.ts
diff --git a/src/auth/guards/optional-jwt-access-token.guard.ts b/apps/selfhosted/src/auth/guards/optional-jwt-access-token.guard.ts
similarity index 100%
rename from src/auth/guards/optional-jwt-access-token.guard.ts
rename to apps/selfhosted/src/auth/guards/optional-jwt-access-token.guard.ts
diff --git a/selfhosted-src/auth/guards/roles.guard.ts b/apps/selfhosted/src/auth/guards/roles.guard.ts
similarity index 83%
rename from selfhosted-src/auth/guards/roles.guard.ts
rename to apps/selfhosted/src/auth/guards/roles.guard.ts
index 927c92124..210476d16 100644
--- a/selfhosted-src/auth/guards/roles.guard.ts
+++ b/apps/selfhosted/src/auth/guards/roles.guard.ts
@@ -3,15 +3,13 @@ import { Reflector } from '@nestjs/core'
import { ExtractJwt } from 'passport-jwt'
import { verify } from 'jsonwebtoken'
-import { UserType } from 'selfhosted-src/user/entities/user.entity'
-import { JWT_ACCESS_TOKEN_SECRET } from 'selfhosted-src/common/constants'
+import { UserType } from 'src/user/entities/user.entity'
+import { JWT_ACCESS_TOKEN_SECRET } from 'src/common/constants'
import { ROLES_KEY } from '../decorators'
@Injectable()
export class RolesGuard implements CanActivate {
- constructor(
- private readonly reflector: Reflector,
- ) {}
+ constructor(private readonly reflector: Reflector) {}
async canActivate(context: ExecutionContext) {
const roles = this.reflector.get<UserType[]>(
diff --git a/src/auth/interfaces/index.ts b/apps/selfhosted/src/auth/interfaces/index.ts
similarity index 100%
rename from src/auth/interfaces/index.ts
rename to apps/selfhosted/src/auth/interfaces/index.ts
diff --git a/src/auth/interfaces/jwt-payload.interface.ts b/apps/selfhosted/src/auth/interfaces/jwt-payload.interface.ts
similarity index 100%
rename from src/auth/interfaces/jwt-payload.interface.ts
rename to apps/selfhosted/src/auth/interfaces/jwt-payload.interface.ts
diff --git a/src/auth/strategies/index.ts b/apps/selfhosted/src/auth/strategies/index.ts
similarity index 71%
rename from src/auth/strategies/index.ts
rename to apps/selfhosted/src/auth/strategies/index.ts
index f544f42d4..20e4bbdce 100644
--- a/src/auth/strategies/index.ts
+++ b/apps/selfhosted/src/auth/strategies/index.ts
@@ -1,3 +1,2 @@
export * from './jwt-access-token.strategy'
export * from './jwt-refresh-token.strategy'
-export * from './api-key.strategy'
diff --git a/selfhosted-src/auth/strategies/jwt-access-token.strategy.ts b/apps/selfhosted/src/auth/strategies/jwt-access-token.strategy.ts
similarity index 66%
rename from selfhosted-src/auth/strategies/jwt-access-token.strategy.ts
rename to apps/selfhosted/src/auth/strategies/jwt-access-token.strategy.ts
index ede9ce01a..2d877c036 100644
--- a/selfhosted-src/auth/strategies/jwt-access-token.strategy.ts
+++ b/apps/selfhosted/src/auth/strategies/jwt-access-token.strategy.ts
@@ -6,8 +6,8 @@ import { Strategy, ExtractJwt } from 'passport-jwt'
import {
SELFHOSTED_UUID,
JWT_ACCESS_TOKEN_SECRET,
-} from 'selfhosted-src/common/constants'
-import { generateSelfhostedUser } from 'selfhosted-src/user/entities/user.entity'
+} from 'src/common/constants'
+import { generateSelfhostedUser } from 'src/user/entities/user.entity'
import { IJwtPayload } from '../interfaces'
@Injectable()
@@ -15,9 +15,7 @@ export class JwtAccessTokenStrategy extends PassportStrategy(
Strategy,
'jwt-access-token',
) {
- constructor(
- public readonly configService: ConfigService,
- ) {
+ constructor(public readonly configService: ConfigService) {
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration: false,
@@ -26,10 +24,10 @@ export class JwtAccessTokenStrategy extends PassportStrategy(
}
public async validate(payload: IJwtPayload) {
- if (payload.sub !== SELFHOSTED_UUID) {
- throw new UnauthorizedException()
- }
+ if (payload.sub !== SELFHOSTED_UUID) {
+ throw new UnauthorizedException()
+ }
- return generateSelfhostedUser()
+ return generateSelfhostedUser()
}
}
diff --git a/src/auth/strategies/jwt-refresh-token.strategy.ts b/apps/selfhosted/src/auth/strategies/jwt-refresh-token.strategy.ts
similarity index 100%
rename from src/auth/strategies/jwt-refresh-token.strategy.ts
rename to apps/selfhosted/src/auth/strategies/jwt-refresh-token.strategy.ts
diff --git a/selfhosted-src/common/constants.ts b/apps/selfhosted/src/common/constants.ts
similarity index 100%
rename from selfhosted-src/common/constants.ts
rename to apps/selfhosted/src/common/constants.ts
diff --git a/src/common/decorators/bot-detection.decorator.ts b/apps/selfhosted/src/common/decorators/bot-detection.decorator.ts
similarity index 100%
rename from src/common/decorators/bot-detection.decorator.ts
rename to apps/selfhosted/src/common/decorators/bot-detection.decorator.ts
diff --git a/src/common/guards/bot-detection.guard.ts b/apps/selfhosted/src/common/guards/bot-detection.guard.ts
similarity index 100%
rename from src/common/guards/bot-detection.guard.ts
rename to apps/selfhosted/src/common/guards/bot-detection.guard.ts
diff --git a/src/common/pagination/index.ts b/apps/selfhosted/src/common/pagination/index.ts
similarity index 100%
rename from src/common/pagination/index.ts
rename to apps/selfhosted/src/common/pagination/index.ts
diff --git a/src/common/pagination/pagination.options.interface.ts b/apps/selfhosted/src/common/pagination/pagination.options.interface.ts
similarity index 100%
rename from src/common/pagination/pagination.options.interface.ts
rename to apps/selfhosted/src/common/pagination/pagination.options.interface.ts
diff --git a/src/common/pagination/pagination.results.interface.ts b/apps/selfhosted/src/common/pagination/pagination.results.interface.ts
similarity index 100%
rename from src/common/pagination/pagination.results.interface.ts
rename to apps/selfhosted/src/common/pagination/pagination.results.interface.ts
diff --git a/src/common/pagination/pagination.ts b/apps/selfhosted/src/common/pagination/pagination.ts
similarity index 100%
rename from src/common/pagination/pagination.ts
rename to apps/selfhosted/src/common/pagination/pagination.ts
diff --git a/selfhosted-src/common/utils.ts b/apps/selfhosted/src/common/utils.ts
similarity index 100%
rename from selfhosted-src/common/utils.ts
rename to apps/selfhosted/src/common/utils.ts
diff --git a/src/configs/i18n.config.ts b/apps/selfhosted/src/configs/i18n.config.ts
similarity index 100%
rename from src/configs/i18n.config.ts
rename to apps/selfhosted/src/configs/i18n.config.ts
diff --git a/src/configs/index.ts b/apps/selfhosted/src/configs/index.ts
similarity index 100%
rename from src/configs/index.ts
rename to apps/selfhosted/src/configs/index.ts
diff --git a/src/i18n/en/auth.json b/apps/selfhosted/src/i18n/en/auth.json
similarity index 100%
rename from src/i18n/en/auth.json
rename to apps/selfhosted/src/i18n/en/auth.json
diff --git a/src/i18n/en/user.json b/apps/selfhosted/src/i18n/en/user.json
similarity index 100%
rename from src/i18n/en/user.json
rename to apps/selfhosted/src/i18n/en/user.json
diff --git a/src/i18n/en/validation.json b/apps/selfhosted/src/i18n/en/validation.json
similarity index 100%
rename from src/i18n/en/validation.json
rename to apps/selfhosted/src/i18n/en/validation.json
diff --git a/src/logger/logger.module.ts b/apps/selfhosted/src/logger/logger.module.ts
similarity index 100%
rename from src/logger/logger.module.ts
rename to apps/selfhosted/src/logger/logger.module.ts
diff --git a/src/logger/logger.service.ts b/apps/selfhosted/src/logger/logger.service.ts
similarity index 100%
rename from src/logger/logger.service.ts
rename to apps/selfhosted/src/logger/logger.service.ts
diff --git a/selfhosted-src/main.ts b/apps/selfhosted/src/main.ts
similarity index 100%
rename from selfhosted-src/main.ts
rename to apps/selfhosted/src/main.ts
diff --git a/src/ping/ping.controller.ts b/apps/selfhosted/src/ping/ping.controller.ts
similarity index 100%
rename from src/ping/ping.controller.ts
rename to apps/selfhosted/src/ping/ping.controller.ts
diff --git a/src/ping/ping.module.ts b/apps/selfhosted/src/ping/ping.module.ts
similarity index 100%
rename from src/ping/ping.module.ts
rename to apps/selfhosted/src/ping/ping.module.ts
diff --git a/src/project/dto/project.dto.ts b/apps/selfhosted/src/project/dto/project.dto.ts
similarity index 100%
rename from src/project/dto/project.dto.ts
rename to apps/selfhosted/src/project/dto/project.dto.ts
diff --git a/selfhosted-src/project/entity/index.ts b/apps/selfhosted/src/project/entity/index.ts
similarity index 100%
rename from selfhosted-src/project/entity/index.ts
rename to apps/selfhosted/src/project/entity/index.ts
diff --git a/selfhosted-src/project/entity/project.entity.ts b/apps/selfhosted/src/project/entity/project.entity.ts
similarity index 96%
rename from selfhosted-src/project/entity/project.entity.ts
rename to apps/selfhosted/src/project/entity/project.entity.ts
index 8fb9117aa..dbe0df792 100644
--- a/selfhosted-src/project/entity/project.entity.ts
+++ b/apps/selfhosted/src/project/entity/project.entity.ts
@@ -1,9 +1,15 @@
export class Project {
id: string
+
name: string
+
origins: string[]
+
ipBlacklist: string[]
+
active: boolean
+
public: boolean
+
created: Date
}
diff --git a/selfhosted-src/project/project.controller.ts b/apps/selfhosted/src/project/project.controller.ts
similarity index 69%
rename from selfhosted-src/project/project.controller.ts
rename to apps/selfhosted/src/project/project.controller.ts
index fa3f3cfc7..1db78e220 100644
--- a/selfhosted-src/project/project.controller.ts
+++ b/apps/selfhosted/src/project/project.controller.ts
@@ -21,13 +21,10 @@ import * as _split from 'lodash/split'
import * as _head from 'lodash/head'
import * as dayjs from 'dayjs'
-import { JwtAccessTokenGuard } from 'selfhosted-src/auth/guards'
-import { Auth } from 'selfhosted-src/auth/decorators'
-import { isValidDate } from 'selfhosted-src/analytics/analytics.service'
-import {
- ProjectService,
- deleteProjectRedis,
-} from './project.service'
+import { JwtAccessTokenGuard } from 'src/auth/guards'
+import { Auth } from 'src/auth/decorators'
+import { isValidDate } from 'src/analytics/analytics.service'
+import { ProjectService, deleteProjectRedis } from './project.service'
import { UserType } from '../user/entities/user.entity'
import { Roles } from '../auth/decorators/roles.decorator'
import { RolesGuard } from '../auth/guards/roles.guard'
@@ -36,10 +33,7 @@ import { Project } from './entity/project.entity'
import { CurrentUserId } from '../auth/decorators/current-user-id.decorator'
import { ProjectDTO } from './dto/project.dto'
import { AppLoggerService } from '../logger/logger.service'
-import {
- isValidPID,
- clickhouse,
-} from '../common/constants'
+import { isValidPID, clickhouse } from '../common/constants'
import {
getProjectsClickhouse,
createProjectClickhouse,
@@ -69,14 +63,14 @@ export class ProjectController {
): Promise<Pagination<Project> | Project[] | object> {
this.logger.log({ userId, take, skip }, 'GET /project')
- const results = await getProjectsClickhouse()
- const formatted = _map(results, this.projectService.formatFromClickhouse)
- return {
- results: formatted,
- page_total: _size(formatted),
- total: _size(formatted),
- totalMonthlyEvents: 0, // not needed as it's selfhosed
- }
+ const results = await getProjectsClickhouse()
+ const formatted = _map(results, this.projectService.formatFromClickhouse)
+ return {
+ results: formatted,
+ page_total: _size(formatted),
+ total: _size(formatted),
+ totalMonthlyEvents: 0, // not needed as it's selfhosed
+ }
}
@Get('/names')
@@ -85,9 +79,9 @@ export class ProjectController {
async getNames(@CurrentUserId() userId: string): Promise<Project[]> {
this.logger.log({ userId }, 'GET /project/names')
- const results = await getProjectsClickhouse()
- const formatted = _map(results, this.projectService.formatFromClickhouse)
- return formatted
+ const results = await getProjectsClickhouse()
+ const formatted = _map(results, this.projectService.formatFromClickhouse)
+ return formatted
}
@Post('/')
@@ -100,20 +94,20 @@ export class ProjectController {
): Promise<Project> {
this.logger.log({ projectDTO, userId }, 'POST /project')
- const projects = await getProjectsClickhouse()
+ const projects = await getProjectsClickhouse()
- this.projectService.validateProject(projectDTO)
- this.projectService.checkIfIDUniqueClickhouse(projects, projectDTO.id)
+ this.projectService.validateProject(projectDTO)
+ this.projectService.checkIfIDUniqueClickhouse(projects, projectDTO.id)
- const project = new Project()
- Object.assign(project, projectDTO)
- project.origins = _map(projectDTO.origins, _trim)
- project.ipBlacklist = _map(projectDTO.ipBlacklist, _trim)
- project.active = true
+ const project = new Project()
+ Object.assign(project, projectDTO)
+ project.origins = _map(projectDTO.origins, _trim)
+ project.ipBlacklist = _map(projectDTO.ipBlacklist, _trim)
+ project.active = true
- await createProjectClickhouse(project)
+ await createProjectClickhouse(project)
- return project
+ return project
}
@Delete('/reset/:id')
@@ -132,17 +126,17 @@ export class ProjectController {
)
}
- const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`
- const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`
-
- try {
- await clickhouse.query(query1).toPromise()
- await clickhouse.query(query2).toPromise()
- return 'Project resetted successfully'
- } catch (e) {
- this.logger.error(e)
- return 'Error while resetting your project'
- }
+ const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`
+ const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`
+
+ try {
+ await clickhouse.query(query1).toPromise()
+ await clickhouse.query(query2).toPromise()
+ return 'Project resetted successfully'
+ } catch (e) {
+ this.logger.error(e)
+ return 'Error while resetting your project'
+ }
}
@Delete('/partially/:pid')
@@ -213,19 +207,19 @@ export class ProjectController {
)
}
- await deleteProjectClickhouse(id)
+ await deleteProjectClickhouse(id)
- const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`
- const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`
+ const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`
+ const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`
- try {
- await clickhouse.query(query1).toPromise()
- await clickhouse.query(query2).toPromise()
- return 'Project deleted successfully'
- } catch (e) {
- this.logger.error(e)
- return 'Error while deleting your project'
- }
+ try {
+ await clickhouse.query(query1).toPromise()
+ await clickhouse.query(query2).toPromise()
+ return 'Project deleted successfully'
+ } catch (e) {
+ this.logger.error(e)
+ return 'Error while deleting your project'
+ }
}
@Put('/:id')
@@ -242,19 +236,19 @@ export class ProjectController {
this.projectService.validateProject(projectDTO)
const project = await getProjectsClickhouse(id)
- if (_isEmpty(project)) {
- throw new NotFoundException()
- }
+ if (_isEmpty(project)) {
+ throw new NotFoundException()
+ }
- project.active = projectDTO.active
- project.origins = _map(projectDTO.origins, _trim)
- project.ipBlacklist = _map(projectDTO.ipBlacklist, _trim)
- project.name = projectDTO.name
- project.public = projectDTO.public
+ project.active = projectDTO.active
+ project.origins = _map(projectDTO.origins, _trim)
+ project.ipBlacklist = _map(projectDTO.ipBlacklist, _trim)
+ project.name = projectDTO.name
+ project.public = projectDTO.public
- await updateProjectClickhouse(
- this.projectService.formatToClickhouse(project),
- )
+ await updateProjectClickhouse(
+ this.projectService.formatToClickhouse(project),
+ )
// await updateProjectRedis(id, project)
await deleteProjectRedis(id)
@@ -284,6 +278,6 @@ export class ProjectController {
this.projectService.allowedToView(project, uid)
- return this.projectService.formatFromClickhouse(project)
+ return this.projectService.formatFromClickhouse(project)
}
}
diff --git a/selfhosted-src/project/project.module.ts b/apps/selfhosted/src/project/project.module.ts
similarity index 89%
rename from selfhosted-src/project/project.module.ts
rename to apps/selfhosted/src/project/project.module.ts
index 9566bc47e..860e4e9f1 100644
--- a/selfhosted-src/project/project.module.ts
+++ b/apps/selfhosted/src/project/project.module.ts
@@ -5,9 +5,7 @@ import { ProjectController } from './project.controller'
import { AppLoggerModule } from '../logger/logger.module'
@Module({
- imports: [
- AppLoggerModule,
- ],
+ imports: [AppLoggerModule],
providers: [ProjectService],
exports: [ProjectService],
controllers: [ProjectController],
diff --git a/selfhosted-src/project/project.service.ts b/apps/selfhosted/src/project/project.service.ts
similarity index 99%
rename from selfhosted-src/project/project.service.ts
rename to apps/selfhosted/src/project/project.service.ts
index 33c899d17..b4573e329 100644
--- a/selfhosted-src/project/project.service.ts
+++ b/apps/selfhosted/src/project/project.service.ts
@@ -78,10 +78,7 @@ export class ProjectService {
}
allowedToView(project: Project, uid: string | null): void {
- if (
- project.public ||
- uid
- ) {
+ if (project.public || uid) {
return null
}
diff --git a/selfhosted-src/task-manager/task-manager.module.ts b/apps/selfhosted/src/task-manager/task-manager.module.ts
similarity index 87%
rename from selfhosted-src/task-manager/task-manager.module.ts
rename to apps/selfhosted/src/task-manager/task-manager.module.ts
index 8ced816d5..74f9eaa3e 100644
--- a/selfhosted-src/task-manager/task-manager.module.ts
+++ b/apps/selfhosted/src/task-manager/task-manager.module.ts
@@ -3,9 +3,7 @@ import { TaskManagerService } from './task-manager.service'
import { AppLoggerModule } from '../logger/logger.module'
@Module({
- imports: [
- AppLoggerModule,
- ],
+ imports: [AppLoggerModule],
providers: [TaskManagerService],
exports: [TaskManagerService],
})
diff --git a/selfhosted-src/task-manager/task-manager.service.ts b/apps/selfhosted/src/task-manager/task-manager.service.ts
similarity index 98%
rename from selfhosted-src/task-manager/task-manager.service.ts
rename to apps/selfhosted/src/task-manager/task-manager.service.ts
index 052a0a9c0..51be5d2c6 100644
--- a/selfhosted-src/task-manager/task-manager.service.ts
+++ b/apps/selfhosted/src/task-manager/task-manager.service.ts
@@ -24,9 +24,7 @@ dayjs.extend(utc)
@Injectable()
export class TaskManagerService {
- constructor(
- private readonly logger: AppLoggerService,
- ) {}
+ constructor(private readonly logger: AppLoggerService) {}
@Cron(CronExpression.EVERY_MINUTE)
async saveLogData(): Promise<void> {
diff --git a/selfhosted-src/user/entities/user.entity.ts b/apps/selfhosted/src/user/entities/user.entity.ts
similarity index 100%
rename from selfhosted-src/user/entities/user.entity.ts
rename to apps/selfhosted/src/user/entities/user.entity.ts
diff --git a/selfhosted-src/user/user.controller.ts b/apps/selfhosted/src/user/user.controller.ts
similarity index 78%
rename from selfhosted-src/user/user.controller.ts
rename to apps/selfhosted/src/user/user.controller.ts
index 281fbb477..70de626d1 100644
--- a/selfhosted-src/user/user.controller.ts
+++ b/apps/selfhosted/src/user/user.controller.ts
@@ -1,11 +1,7 @@
-import {
- Controller,
- Get,
- UseGuards,
-} from '@nestjs/common'
+import { Controller, Get, UseGuards } from '@nestjs/common'
import { ApiTags } from '@nestjs/swagger'
-import { JwtAccessTokenGuard } from 'selfhosted-src/auth/guards'
+import { JwtAccessTokenGuard } from 'src/auth/guards'
import {
UserType,
SelfhostedUser,
@@ -20,9 +16,7 @@ import { AppLoggerService } from '../logger/logger.service'
@Controller('user')
@UseGuards(JwtAccessTokenGuard, RolesGuard)
export class UserController {
- constructor(
- private readonly logger: AppLoggerService,
- ) {}
+ constructor(private readonly logger: AppLoggerService) {}
@Get('/me')
@UseGuards(RolesGuard)
diff --git a/selfhosted-src/user/user.module.ts b/apps/selfhosted/src/user/user.module.ts
similarity index 100%
rename from selfhosted-src/user/user.module.ts
rename to apps/selfhosted/src/user/user.module.ts
diff --git a/selfhosted-src/user/user.service.ts b/apps/selfhosted/src/user/user.service.ts
similarity index 99%
rename from selfhosted-src/user/user.service.ts
rename to apps/selfhosted/src/user/user.service.ts
index 5de22cd66..aa11b6ab1 100644
--- a/selfhosted-src/user/user.service.ts
+++ b/apps/selfhosted/src/user/user.service.ts
@@ -3,5 +3,4 @@ import { Injectable } from '@nestjs/common'
@Injectable()
export class UserService {
constructor() {}
-
}
diff --git a/apps/selfhosted/tsconfig.app.json b/apps/selfhosted/tsconfig.app.json
new file mode 100644
index 000000000..d8e88dc36
--- /dev/null
+++ b/apps/selfhosted/tsconfig.app.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "declaration": true,
+ "removeComments": true,
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "allowSyntheticDefaultImports": true,
+ "target": "es2017",
+ "sourceMap": true,
+ "outDir": "./dist",
+ "baseUrl": "./",
+ "incremental": true,
+ "skipLibCheck": true
+ }
+}
diff --git a/nest-cli.json b/nest-cli.json
index db6c46bc0..e82c58c83 100644
--- a/nest-cli.json
+++ b/nest-cli.json
@@ -1,10 +1,33 @@
{
"collection": "@nestjs/schematics",
- "sourceRoot": "src",
+ "sourceRoot": "apps/production/src",
+ "root": "apps/production",
+ "monorepo": true,
"compilerOptions": {
"assets": [
{ "include": "common/templates/**/*", "watchAssets": true },
{ "include": "i18n/**/*", "watchAssets": true }
- ]
+ ],
+ "tsConfigPath": "apps/production/tsconfig.app.json"
+ },
+ "projects": {
+ "production": {
+ "type": "application",
+ "root": "apps/production",
+ "entryFile": "main",
+ "sourceRoot": "apps/production/src",
+ "compilerOptions": {
+ "tsConfigPath": "apps/production/tsconfig.app.json"
+ }
+ },
+ "selfhosted": {
+ "type": "application",
+ "root": "apps/selfhosted",
+ "entryFile": "main",
+ "sourceRoot": "apps/selfhosted/src",
+ "compilerOptions": {
+ "tsConfigPath": "apps/selfhosted/tsconfig.app.json"
+ }
+ }
}
}
diff --git a/package.json b/package.json
index bf599ae82..e8b8abb6e 100644
--- a/package.json
+++ b/package.json
@@ -10,13 +10,15 @@
"prebuild": "rimraf dist",
"build": "nest build",
"postbuild": "cp .env dist/.env",
- "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
+ "build:selfhosted": "npm run prebuild && nest build selfhosted && npm run postbuild",
+ "format": "prettier --write \"apps/**/*.ts\" \"test/**/*.ts\"",
"start": "cross-env NODE_ENV=development nest start",
"start:dev": "cross-env NODE_ENV=development nest start --watch",
+ "start:selfhosted": "cross-env NODE_ENV=development nest start selfhosted --watch",
"start:debug": "cross-env NODE_ENV=development nest start --debug --watch",
"start:prod": "cross-env NODE_ENV=production node dist/main",
- "lint": "eslint \"{src,test}/**/*.ts\"",
- "lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
+ "lint": "eslint \"{apps,test}/**/*.ts\"",
+ "lint:fix": "eslint \"{apps,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
diff --git a/selfhosted-src/auth/guards/api-key-rate-limit.guard.ts b/selfhosted-src/auth/guards/api-key-rate-limit.guard.ts
deleted file mode 100644
index 35f6e4fbd..000000000
--- a/selfhosted-src/auth/guards/api-key-rate-limit.guard.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'
-import { checkRateLimitForApiKey } from 'selfhosted-src/common/utils'
-import { ACCOUNT_PLANS, PlanCode } from 'selfhosted-src/user/entities/user.entity'
-
-@Injectable()
-export class ApiKeyRateLimitGuard implements CanActivate {
- async canActivate(context: ExecutionContext) {
- const request = context.switchToHttp().getRequest()
- const { user } = request
-
- if (request.headers['x-api-key']) {
- if (!user) return false
-
- const reqAmount =
- ACCOUNT_PLANS[user.planCode as PlanCode].maxApiKeyRequestsPerHour
- return checkRateLimitForApiKey(user.apiKey, reqAmount)
- }
-
- return true
- }
-}
diff --git a/src/auth/strategies/api-key.strategy.ts b/src/auth/strategies/api-key.strategy.ts
deleted file mode 100644
index e87cae9a9..000000000
--- a/src/auth/strategies/api-key.strategy.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { Injectable, UnauthorizedException } from '@nestjs/common'
-import { PassportStrategy } from '@nestjs/passport'
-import { HeaderAPIKeyStrategy } from 'passport-headerapikey'
-import { AuthService } from '../auth.service'
-
-@Injectable()
-export class ApiKeyStrategy extends PassportStrategy(
- HeaderAPIKeyStrategy,
- 'api-key',
-) {
- constructor(private readonly authService: AuthService) {
- super(
- { header: 'X-Api-Key', prefix: '' },
- true,
- // eslint-disable-next-line consistent-return
- async (apiKey: string, done: any) => {
- const user = await this.authService.validateApiKey(apiKey)
- if (!user) return done(new UnauthorizedException(), false)
- done(null, user)
- },
- )
- }
-}
diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts
deleted file mode 100644
index b3098d520..000000000
--- a/test/app.e2e-spec.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Test, TestingModule } from '@nestjs/testing'
-import { INestApplication } from '@nestjs/common'
-import * as request from 'supertest'
-import { AppModule } from '../src/app.module'
-
-describe('AppController (e2e)', () => {
- let app: INestApplication
-
- beforeEach(async () => {
- const moduleFixture: TestingModule = await Test.createTestingModule({
- imports: [AppModule],
- }).compile()
-
- app = moduleFixture.createNestApplication()
- await app.init()
- })
-
- it('/ (GET)', () => {
- return request(app.getHttpServer())
- .get('/')
- .expect(200)
- .expect('Hello World!')
- })
-})
diff --git a/test/jest-e2e.json b/test/jest-e2e.json
deleted file mode 100644
index e9d912f3e..000000000
--- a/test/jest-e2e.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "moduleFileExtensions": ["js", "json", "ts"],
- "rootDir": ".",
- "testEnvironment": "node",
- "testRegex": ".e2e-spec.ts$",
- "transform": {
- "^.+\\.(t|j)s$": "ts-jest"
- }
-}