Skip to content

Commit

Permalink
chore(api): Reorganized import using path alias
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Sep 5, 2024
1 parent 434ad87 commit b4491ce
Show file tree
Hide file tree
Showing 79 changed files with 421 additions and 424 deletions.
3 changes: 3 additions & 0 deletions apps/api/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default {
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }]
},
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/api'
}
3 changes: 3 additions & 0 deletions apps/api/jest.e2e-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default {
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }]
},
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/api'
}
8 changes: 4 additions & 4 deletions apps/api/src/api-key/api-key.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import {
FastifyAdapter,
NestFastifyApplication
} from '@nestjs/platform-fastify'
import { PrismaService } from '../prisma/prisma.service'
import { PrismaService } from '@/prisma/prisma.service'
import { ApiKeyModule } from './api-key.module'
import { MAIL_SERVICE } from '../mail/services/interface.service'
import { MockMailService } from '../mail/services/mock.service'
import { AppModule } from '../app/app.module'
import { MAIL_SERVICE } from '@/mail/services/interface.service'
import { MockMailService } from '@/mail/services/mock.service'
import { AppModule } from '@/app/app.module'
import { Test } from '@nestjs/testing'
import { ApiKey, Authority, User } from '@prisma/client'
import { ApiKeyService } from './service/api-key.service'
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/api-key/controller/api-key.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Test, TestingModule } from '@nestjs/testing'
import { ApiKeyController } from './api-key.controller'
import { ApiKeyService } from '../service/api-key.service'
import { PrismaService } from '../../prisma/prisma.service'
import { PrismaService } from '@/prisma/prisma.service'
import { mockDeep } from 'jest-mock-extended'
import { ApiKeyService } from '@/api-key/service/api-key.service'

describe('ApiKeyController', () => {
let controller: ApiKeyController
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/api-key/controller/api-key.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
Query
} from '@nestjs/common'
import { ApiKeyService } from '../service/api-key.service'
import { CurrentUser } from '../../decorators/user.decorator'
import { CurrentUser } from '@/decorators/user.decorator'
import { CreateApiKey } from '../dto/create.api-key/create.api-key'
import { UpdateApiKey } from '../dto/update.api-key/update.api-key'
import { Authority, User } from '@prisma/client'
import { RequiredApiKeyAuthorities } from '../../decorators/required-api-key-authorities.decorator'
import { RequiredApiKeyAuthorities } from '@/decorators/required-api-key-authorities.decorator'

@Controller('api-key')
export class ApiKeyController {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/api-key/service/api-key.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing'
import { ApiKeyService } from './api-key.service'
import { PrismaService } from '../../prisma/prisma.service'
import { PrismaService } from '@/prisma/prisma.service'
import { mockDeep } from 'jest-mock-extended'

describe('ApiKeyService', () => {
Expand Down
10 changes: 5 additions & 5 deletions apps/api/src/api-key/service/api-key.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import {
Logger,
NotFoundException
} from '@nestjs/common'
import { PrismaService } from '../../prisma/prisma.service'
import { PrismaService } from '@/prisma/prisma.service'
import { CreateApiKey } from '../dto/create.api-key/create.api-key'
import { addHoursToDate } from '../../common/add-hours-to-date'
import { generateApiKey } from '../../common/api-key-generator'
import { toSHA256 } from '../../common/to-sha256'
import { addHoursToDate } from '@/common/add-hours-to-date'
import { generateApiKey } from '@/common/api-key-generator'
import { toSHA256 } from '@/common/to-sha256'
import { UpdateApiKey } from '../dto/update.api-key/update.api-key'
import { ApiKey, User } from '@prisma/client'
import { limitMaxItemsPerPage } from '../../common/limit-max-items-per-page'
import { limitMaxItemsPerPage } from '@/common/limit-max-items-per-page'

@Injectable()
export class ApiKeyService {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller, Get } from '@nestjs/common'
import { Public } from '../decorators/public.decorator'
import { Public } from '@/decorators/public.decorator'

@Controller()
export class AppController {
Expand Down
40 changes: 20 additions & 20 deletions apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ import { Module } from '@nestjs/common'
import { AppController } from './app.controller'
import { ConfigModule } from '@nestjs/config'
import { PassportModule } from '@nestjs/passport'
import { AuthModule } from '../auth/auth.module'
import { PrismaModule } from '../prisma/prisma.module'
import { CommonModule } from '../common/common.module'
import { MailModule } from '../mail/mail.module'
import { AuthModule } from '@/auth/auth.module'
import { PrismaModule } from '@/prisma/prisma.module'
import { CommonModule } from '@/common/common.module'
import { MailModule } from '@/mail/mail.module'
import { APP_GUARD } from '@nestjs/core'
import { AuthGuard } from '../auth/guard/auth/auth.guard'
import { UserModule } from '../user/user.module'
import { ProjectModule } from '../project/project.module'
import { EnvironmentModule } from '../environment/environment.module'
import { ApiKeyModule } from '../api-key/api-key.module'
import { WorkspaceModule } from '../workspace/workspace.module'
import { WorkspaceRoleModule } from '../workspace-role/workspace-role.module'
import { ApiKeyGuard } from '../auth/guard/api-key/api-key.guard'
import { EventModule } from '../event/event.module'
import { VariableModule } from '../variable/variable.module'
import { SocketModule } from '../socket/socket.module'
import { ProviderModule } from '../provider/provider.module'
import { AuthGuard } from '@/auth/guard/auth/auth.guard'
import { UserModule } from '@/user/user.module'
import { ProjectModule } from '@/project/project.module'
import { EnvironmentModule } from '@/environment/environment.module'
import { ApiKeyModule } from '@/api-key/api-key.module'
import { WorkspaceModule } from '@/workspace/workspace.module'
import { WorkspaceRoleModule } from '@/workspace-role/workspace-role.module'
import { ApiKeyGuard } from '@/auth/guard/api-key/api-key.guard'
import { EventModule } from '@/event/event.module'
import { VariableModule } from '@/variable/variable.module'
import { SocketModule } from '@/socket/socket.module'
import { ProviderModule } from '@/provider/provider.module'
import { ScheduleModule } from '@nestjs/schedule'
import { EnvSchema } from '../common/env/env.schema'
import { IntegrationModule } from '../integration/integration.module'
import { FeedbackModule } from '../feedback/feedback.module'
import { CacheModule } from '../cache/cache.module'
import { EnvSchema } from '@/common/env/env.schema'
import { IntegrationModule } from '@/integration/integration.module'
import { FeedbackModule } from '@/feedback/feedback.module'
import { CacheModule } from '@/cache/cache.module'

@Module({
controllers: [AppController],
Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/auth/auth.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {
FastifyAdapter,
NestFastifyApplication
} from '@nestjs/platform-fastify'
import { PrismaService } from '../prisma/prisma.service'
import { PrismaService } from '@/prisma/prisma.service'
import { Test } from '@nestjs/testing'
import { AuthModule } from './auth.module'
import { MAIL_SERVICE } from '../mail/services/interface.service'
import { MockMailService } from '../mail/services/mock.service'
import { AppModule } from '../app/app.module'
import { MAIL_SERVICE } from '@/mail/services/interface.service'
import { MockMailService } from '@/mail/services/mock.service'
import { AppModule } from '@/app/app.module'
import { AuthService } from './service/auth.service'

describe('Auth Controller Tests', () => {
Expand Down
14 changes: 7 additions & 7 deletions apps/api/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { Module } from '@nestjs/common'
import { AuthService } from './service/auth.service'
import { AuthController } from './controller/auth.controller'
import { JwtModule } from '@nestjs/jwt'
import { UserModule } from '../user/user.module'
import { GithubStrategy } from '../config/oauth-strategy/github/github.strategy'
import { GithubOAuthStrategyFactory } from '../config/factory/github/github-strategy.factory'
import { GoogleOAuthStrategyFactory } from '../config/factory/google/google-strategy.factory'
import { GoogleStrategy } from '../config/oauth-strategy/google/google.strategy'
import { GitlabOAuthStrategyFactory } from '../config/factory/gitlab/gitlab-strategy.factory'
import { GitlabStrategy } from '../config/oauth-strategy/gitlab/gitlab.strategy'
import { UserModule } from '@/user/user.module'
import { GithubStrategy } from '@/config/oauth-strategy/github/github.strategy'
import { GithubOAuthStrategyFactory } from '@/config/factory/github/github-strategy.factory'
import { GoogleOAuthStrategyFactory } from '@/config/factory/google/google-strategy.factory'
import { GoogleStrategy } from '@/config/oauth-strategy/google/google.strategy'
import { GitlabOAuthStrategyFactory } from '@/config/factory/gitlab/gitlab-strategy.factory'
import { GitlabStrategy } from '@/config/oauth-strategy/gitlab/gitlab.strategy'

@Module({
imports: [
Expand Down
16 changes: 8 additions & 8 deletions apps/api/src/auth/controller/auth.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Test, TestingModule } from '@nestjs/testing'
import { AuthService } from '../service/auth.service'
import { MAIL_SERVICE } from '../../mail/services/interface.service'
import { MockMailService } from '../../mail/services/mock.service'
import { MAIL_SERVICE } from '@/mail/services/interface.service'
import { MockMailService } from '@/mail/services/mock.service'
import { JwtService } from '@nestjs/jwt'
import { PrismaService } from '../../prisma/prisma.service'
import { PrismaService } from '@/prisma/prisma.service'
import { AuthController } from './auth.controller'
import { mockDeep } from 'jest-mock-extended'
import { ConfigService } from '@nestjs/config'
import { GithubOAuthStrategyFactory } from '../../config/factory/github/github-strategy.factory'
import { GoogleOAuthStrategyFactory } from '../../config/factory/google/google-strategy.factory'
import { GitlabOAuthStrategyFactory } from '../../config/factory/gitlab/gitlab-strategy.factory'
import { CacheService } from '../../cache/cache.service'
import { REDIS_CLIENT } from '../../provider/redis.provider'
import { GithubOAuthStrategyFactory } from '@/config/factory/github/github-strategy.factory'
import { GoogleOAuthStrategyFactory } from '@/config/factory/google/google-strategy.factory'
import { GitlabOAuthStrategyFactory } from '@/config/factory/gitlab/gitlab-strategy.factory'
import { CacheService } from '@/cache/cache.service'
import { REDIS_CLIENT } from '@/provider/redis.provider'

describe('AuthController', () => {
let controller: AuthController
Expand Down
12 changes: 6 additions & 6 deletions apps/api/src/auth/controller/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ import {
UseGuards
} from '@nestjs/common'
import { AuthService } from '../service/auth.service'
import { Public } from '../../decorators/public.decorator'
import { Public } from '@/decorators/public.decorator'
import { AuthGuard } from '@nestjs/passport'
import { GithubOAuthStrategyFactory } from '../../config/factory/github/github-strategy.factory'
import { GoogleOAuthStrategyFactory } from '../../config/factory/google/google-strategy.factory'
import { GitlabOAuthStrategyFactory } from '../../config/factory/gitlab/gitlab-strategy.factory'
import { GithubOAuthStrategyFactory } from '@/config/factory/github/github-strategy.factory'
import { GoogleOAuthStrategyFactory } from '@/config/factory/google/google-strategy.factory'
import { GitlabOAuthStrategyFactory } from '@/config/factory/gitlab/gitlab-strategy.factory'
import { Response } from 'express'
import { AuthProvider } from '@prisma/client'
import setCookie from '../../common/set-cookie'
import setCookie from '@/common/set-cookie'
import {
sendOAuthFailureRedirect,
sendOAuthSuccessRedirect
} from '../../common/redirect'
} from '@/common/redirect'

@Controller('auth')
export class AuthController {
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/auth/guard/api-key/api-key.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
} from '@nestjs/common'
import { Reflector } from '@nestjs/core'
import { Authority } from '@prisma/client'
import { REQUIRED_API_KEY_AUTHORITIES } from '../../../decorators/required-api-key-authorities.decorator'
import { REQUIRED_API_KEY_AUTHORITIES } from '@/decorators/required-api-key-authorities.decorator'
import { Observable } from 'rxjs'
import { AuthenticatedUserContext } from '../../auth.types'
import { FORBID_API_KEY } from '../../../decorators/forbid-api-key.decorator'
import { IS_PUBLIC_KEY } from '../../../decorators/public.decorator'
import { FORBID_API_KEY } from '@/decorators/forbid-api-key.decorator'
import { IS_PUBLIC_KEY } from '@/decorators/public.decorator'

@Injectable()
export class ApiKeyGuard implements CanActivate {
Expand Down
12 changes: 6 additions & 6 deletions apps/api/src/auth/guard/auth/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
} from '@nestjs/common'
import { JwtService } from '@nestjs/jwt'
import { Reflector } from '@nestjs/core'
import { IS_PUBLIC_KEY } from '../../../decorators/public.decorator'
import { PrismaService } from '../../../prisma/prisma.service'
import { ONBOARDING_BYPASSED } from '../../../decorators/bypass-onboarding.decorator'
import { IS_PUBLIC_KEY } from '@/decorators/public.decorator'
import { PrismaService } from '@/prisma/prisma.service'
import { ONBOARDING_BYPASSED } from '@/decorators/bypass-onboarding.decorator'
import { AuthenticatedUserContext } from '../../auth.types'
import { toSHA256 } from '../../../common/to-sha256'
import { EnvSchema } from '../../../common/env/env.schema'
import { CacheService } from '../../../cache/cache.service'
import { toSHA256 } from '@/common/to-sha256'
import { EnvSchema } from '@/common/env/env.schema'
import { CacheService } from '@/cache/cache.service'

const X_E2E_USER_EMAIL = 'x-e2e-user-email'
const X_KEYSHADE_TOKEN = 'x-keyshade-token'
Expand Down
10 changes: 5 additions & 5 deletions apps/api/src/auth/service/auth.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Test, TestingModule } from '@nestjs/testing'
import { AuthService } from './auth.service'
import { MockMailService } from '../../mail/services/mock.service'
import { MAIL_SERVICE } from '../../mail/services/interface.service'
import { MockMailService } from '@/mail/services/mock.service'
import { MAIL_SERVICE } from '@/mail/services/interface.service'
import { JwtService } from '@nestjs/jwt'
import { PrismaService } from '../../prisma/prisma.service'
import { PrismaService } from '@/prisma/prisma.service'
import { mockDeep } from 'jest-mock-extended'
import { CacheService } from '../../cache/cache.service'
import { REDIS_CLIENT } from '../../provider/redis.provider'
import { CacheService } from '@/cache/cache.service'
import { REDIS_CLIENT } from '@/provider/redis.provider'

describe('AuthService', () => {
let service: AuthService
Expand Down
13 changes: 5 additions & 8 deletions apps/api/src/auth/service/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ import {
import { JwtService } from '@nestjs/jwt'
import { Cron, CronExpression } from '@nestjs/schedule'
import { UserAuthenticatedResponse } from '../auth.types'
import {
IMailService,
MAIL_SERVICE
} from '../../mail/services/interface.service'
import { PrismaService } from '../../prisma/prisma.service'
import createUser from '../../common/create-user'
import { IMailService, MAIL_SERVICE } from '@/mail/services/interface.service'
import { PrismaService } from '@/prisma/prisma.service'
import createUser from '@/common/create-user'
import { AuthProvider } from '@prisma/client'
import generateOtp from '../../common/generate-otp'
import { CacheService } from '../../cache/cache.service'
import generateOtp from '@/common/generate-otp'
import { CacheService } from '@/cache/cache.service'

@Injectable()
export class AuthService {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/cache/cache.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing'
import { CacheService } from './cache.service'
import { REDIS_CLIENT } from '../provider/redis.provider'
import { REDIS_CLIENT } from '@/provider/redis.provider'

describe('CacheService', () => {
let service: CacheService
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/cache/cache.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Injectable, OnModuleDestroy } from '@nestjs/common'
import { RedisClientType } from 'redis'
import { User } from '@prisma/client'
import { REDIS_CLIENT } from '../provider/redis.provider'
import { REDIS_CLIENT } from '@/provider/redis.provider'

@Injectable()
export class CacheService implements OnModuleDestroy {
Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/common/authority-checker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Integration,
ProjectAccessLevel
} from '@prisma/client'
import { VariableWithProjectAndVersion } from '../variable/variable.types'
import { VariableWithProjectAndVersion } from '@/variable/variable.types'
import {
Injectable,
InternalServerErrorException,
Expand All @@ -14,9 +14,9 @@ import {
} from '@nestjs/common'
import getCollectiveProjectAuthorities from './get-collective-project-authorities'
import getCollectiveWorkspaceAuthorities from './get-collective-workspace-authorities'
import { EnvironmentWithProject } from '../environment/environment.types'
import { ProjectWithSecrets } from '../project/project.types'
import { SecretWithProjectAndVersion } from '../secret/secret.types'
import { EnvironmentWithProject } from '@/environment/environment.types'
import { ProjectWithSecrets } from '@/project/project.types'
import { SecretWithProjectAndVersion } from '@/secret/secret.types'
import { CustomLoggerService } from './logger.service'

export interface AuthorityInput {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/common/create-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
Integration
} from '@prisma/client'
import { JsonObject } from '@prisma/client/runtime/library'
import IntegrationFactory from '../integration/plugins/factory/integration.factory'
import IntegrationFactory from '@/integration/plugins/factory/integration.factory'

const logger = new Logger('CreateEvent')

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/common/create-user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AuthProvider, User, Workspace } from '@prisma/client'
import { PrismaService } from '../prisma/prisma.service'
import { CreateUserDto } from '../user/dto/create.user/create.user'
import { PrismaService } from '@/prisma/prisma.service'
import { CreateUserDto } from '@/user/dto/create.user/create.user'
import createWorkspace from './create-workspace'
import { Logger } from '@nestjs/common'

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/common/create-workspace.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Authority, EventSource, EventType, User } from '@prisma/client'
import createEvent from './create-event'
import { CreateWorkspace } from '../workspace/dto/create.workspace/create.workspace'
import { CreateWorkspace } from '@/workspace/dto/create.workspace/create.workspace'
import { v4 } from 'uuid'
import { PrismaService } from '../prisma/prisma.service'
import { PrismaService } from '@/prisma/prisma.service'
import { Logger } from '@nestjs/common'

export default async function createWorkspace(
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/common/set-cookie.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { User } from '@prisma/client'
import { Response } from 'express'
import { UserAuthenticatedResponse } from '../auth/auth.types'
import { UserAuthenticatedResponse } from '@/auth/auth.types'

/* istanbul ignore next */
export default function setCookie(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Test, TestingModule } from '@nestjs/testing'
import { EnvironmentController } from './environment.controller'
import { EnvironmentService } from '../service/environment.service'
import { PrismaService } from '../../prisma/prisma.service'
import { PrismaService } from '@/prisma/prisma.service'
import { mockDeep } from 'jest-mock-extended'
import { AuthorityCheckerService } from '../../common/authority-checker.service'
import { CommonModule } from '../../common/common.module'
import { AuthorityCheckerService } from '@/common/authority-checker.service'
import { CommonModule } from '@/common/common.module'

describe('EnvironmentController', () => {
let controller: EnvironmentController
Expand Down
Loading

0 comments on commit b4491ce

Please sign in to comment.