Skip to content

Commit

Permalink
chore: tweak api aliases to use use shared src ~ alias
Browse files Browse the repository at this point in the history
  • Loading branch information
V-ed committed Dec 21, 2023
1 parent 53a5016 commit 0d67213
Show file tree
Hide file tree
Showing 27 changed files with 37 additions and 34 deletions.
2 changes: 1 addition & 1 deletion api/src/@common/app/home/home.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { HomeController } from './home.controller';

describe('HomeController', () => {
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/email/email.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpModule } from '@nestjs/axios';
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { EmailService } from './email.service';

describe('EmailService', () => {
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/email/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HttpService } from '@nestjs/axios';
import { Injectable } from '@nestjs/common';
import { create as createHandlebars, type ExpressHandlebars } from 'express-handlebars';
import { firstValueFrom } from 'rxjs';
import { Environment, EnvironmentConfig } from '~/env.validation';
import { Environment, EnvironmentConfig } from '~env';
import { sendEmailSchema, SendMailData } from './schemas';

type HbsRenderViewParameters = Parameters<ExpressHandlebars['renderView']>;
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/graphql/context/context.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LuciaModule } from '$users/auth/lucia/lucia.module';
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { ContextService } from './context.service';

describe('ContextService', () => {
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/graphql/graphql.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { GraphQLModule as NestGraphQLModule } from '@nestjs/graphql';
import depthLimit from 'graphql-depth-limit';
import { join } from 'path';
import { Environment, EnvironmentConfig } from '~/env.validation';
import { Environment, EnvironmentConfig } from '~env';
import { ConfigModule } from '../configs/config.module';
import { ContextModule } from './context/context.module';
import { ContextService, type CommonGQLContext, type TypedSubscriptionContext } from './context/context.service';
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/graphql/schema/schema.manager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { schemaPath } from '$graphql/graphql.module';
import { NestFactory } from '@nestjs/core';
import { existsSync } from 'fs';
import { AppModule } from '~/app.module';
import { AppModule } from '~app-module';

export async function ensureGraphQLSchema() {
if (!existsSync(schemaPath)) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/minio/minio-client.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TypedI18nModule } from '$i18n/i18n.module';
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js';
import { MinioModule } from 'nestjs-minio-client';
import { EnvironmentConfig } from '~/env.validation';
import { EnvironmentConfig } from '~env';
import { MinioClientService } from './minio-client.service';

export const GRAPHQL_MAX_FILE_SIZE_MB = 10;
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/minio/minio-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common';
import * as crypto from 'crypto';
import { FileUpload } from 'graphql-upload/Upload.js';
import { MinioService } from 'nestjs-minio-client';
import { EnvironmentConfig } from '~/env.validation';
import { EnvironmentConfig } from '~env';
import { GRAPHQL_MAX_FILE_COUNT, GRAPHQL_MAX_FILE_SIZE_MB } from './minio-client.module';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/users/admin/admin.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Origin } from '$utils/origin.decorator';
import { ForbiddenException } from '@nestjs/common';
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
import { I18n, I18nContext } from 'nestjs-i18n';
import { ADMIN } from '~/@utils/roles';
import { ADMIN } from '~utils/roles';
import { AdminService } from './admin.service';
import { CreateUserOutput } from './dtos/create-user.output';
import { GetUserOutput } from './dtos/getUser.output';
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/users/admin/admin.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AuthModule } from '$users/auth/auth.module';
import { RolesService } from '$users/auth/roles/roles.service';
import { PresenceModule } from '$users/presence/presence.module';
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { AdminService } from './admin.service';

describe('AdminService', () => {
Expand Down
4 changes: 2 additions & 2 deletions api/src/@common/users/admin/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { LiveUser } from '$users/dtos/LiveUser.dto';
import { PresenceService, UserOnlineSelector } from '$users/presence/presence.service';
import { Injectable } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { ADMIN } from '~/@utils/roles';
import { EnvironmentConfig } from '~/env.validation';
import { EnvironmentConfig } from '~env';
import { ADMIN } from '~utils/roles';
import { ADMIN_CREATE_USER_EVENT_KEY, ADMIN_CREATE_USER_EVENT_TYPE } from './listeners/admin.events';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/users/auth/auth.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ConfigModule } from '$configs/config.module';
import { EmailModule } from '$email/email.module';
import { PresenceModule } from '$users/presence/presence.module';
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { AuthService } from './auth.service';
import { LuciaFactory } from './lucia/lucia.factory';
import { RolesModule } from './roles/roles.module';
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/users/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { loadLuciaUtils } from '$users/auth/lucia/modules-compat';
import { PresenceService, UserOnlineSelector } from '$users/presence/presence.service';
import { BadRequestException, Inject, Injectable } from '@nestjs/common';
import type { GlobalDatabaseUserAttributes } from 'lucia';
import { EnvironmentConfig } from '~/env.validation';
import { EnvironmentConfig } from '~env';
import { Auth, LuciaFactory } from './lucia/lucia.factory';
import { LuciaSession } from './session.decorator';

Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/users/auth/lucia/lucia.factory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PrismaClient, User } from '$prisma-client';
import { loadLuciaCryptoNode18, loadLuciaMiddleware, loadLuciaModule, loadPrismaAdapterModule } from '$users/auth/lucia/modules-compat';
import { Environment, type EnvironmentConfig } from '~/env.validation';
import { Environment, type EnvironmentConfig } from '~env';

export async function luciaFactory(prisma: PrismaClient, env: EnvironmentConfig) {
await loadLuciaCryptoNode18();
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/users/auth/roles/roles.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { RoleCreateNestedManyWithoutUsersInput, RoleWhereInput } from '$prisma-g
import { PrismaSelector, PrismaService } from '$prisma/prisma.service';
import { Injectable } from '@nestjs/common';
import { User } from 'lucia';
import { ADMIN } from '~/@utils/roles';
import { ADMIN } from '~utils/roles';

@Injectable()
export class RolesService {
Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/users/presence/presence.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { PresenceService } from './presence.service';

describe('PresenceService', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MinioClientModule } from '$minio/minio-client.module';
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { ProfilePictureController } from './profile-picture.controller';
import { ProfilePictureService } from './profile-picture.service';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MinioClientModule } from '$minio/minio-client.module';
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { ProfilePictureService } from './profile-picture.service';

describe('ProfilePictureService', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PresenceModule } from '$users/presence/presence.module';
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { UserProfileResolver } from './profile.resolver';
import { UserProfileService } from './profile.service';

Expand Down
2 changes: 1 addition & 1 deletion api/src/@common/users/user/profile/profile.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PresenceModule } from '$users/presence/presence.module';
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { UserProfileService } from './profile.service';

describe('UserProfileService', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AuthModule } from '$users/auth/auth.module';
import { LuciaModule } from '$users/auth/lucia/lucia.module';
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { UserSecurityModule } from './security.module';
import { UserSecurityResolver } from './security.resolver';
import { UserSecurityService } from './security.service';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AuthModule } from '$users/auth/auth.module';
import { LuciaModule } from '$users/auth/lucia/lucia.module';
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { UserSecurityService } from './security.service';

describe('UserSecurityService', () => {
Expand Down
2 changes: 1 addition & 1 deletion api/src/message/message.resolver.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { MessageResolver } from './message.resolver';
import { MessageService } from './message.service';

Expand Down
2 changes: 1 addition & 1 deletion api/src/message/message.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { TestManager } from '~/@utils/tests/TestManager';
import { TestManager } from '~utils/tests/TestManager';
import { MessageService } from './message.service';

describe('MessageService', () => {
Expand Down
10 changes: 5 additions & 5 deletions api/tests/mocks/graphql.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ConfigModule } from '$configs/config.module';
import { ContextModule } from '$graphql/context/context.module';
import { CommonContext, ContextService, TypedSubscriptionContext } from '$graphql/context/context.service';
import { CommonGQLContext, ContextService, TypedSubscriptionContext } from '$graphql/context/context.service';
import { schemaPath } from '$graphql/graphql.module';
import { PresenceModule } from '$users/presence/presence.module';
import { PresenceService } from '$users/presence/presence.service';
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { GraphQLModule as NestGraphQLModule } from '@nestjs/graphql';
import depthLimit from 'graphql-depth-limit';
import { EnvironmentConfig } from '~/env.validation';
import { EnvironmentConfig } from '~env';

export const TestGraphqlModule = NestGraphQLModule.forRootAsync<ApolloDriverConfig>({
driver: ApolloDriver,
Expand All @@ -21,7 +21,7 @@ export const TestGraphqlModule = NestGraphQLModule.forRootAsync<ApolloDriverConf
onConnect: async (context) => {
const {
req: { session },
} = await contextService.setupGqlContext(context as TypedSubscriptionContext | CommonContext);
} = await contextService.setupGqlContext(context as TypedSubscriptionContext | CommonGQLContext);

if (session) {
presenceService.onConnect(session);
Expand All @@ -30,7 +30,7 @@ export const TestGraphqlModule = NestGraphQLModule.forRootAsync<ApolloDriverConf
onDisconnect: async (context) => {
const {
req: { session },
} = contextService.extractRawGqlContext(context as TypedSubscriptionContext | CommonContext);
} = contextService.extractRawGqlContext(context as TypedSubscriptionContext | CommonGQLContext);

if (session) {
presenceService.onDisconnect(session);
Expand All @@ -40,7 +40,7 @@ export const TestGraphqlModule = NestGraphQLModule.forRootAsync<ApolloDriverConf
},
playground: false,
validationRules: [depthLimit(env.GRAPHQL_DEPTH_LIMIT)],
context: (context: TypedSubscriptionContext | CommonContext) => contextService.setupGqlContext(context),
context: (context: TypedSubscriptionContext | CommonGQLContext) => contextService.setupGqlContext(context),
};
},
inject: [EnvironmentConfig, ContextService, PresenceService],
Expand Down
6 changes: 3 additions & 3 deletions api/tests/utils/E2ETestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { TestingModuleBuilder } from '@nestjs/testing';
import { User } from 'lucia';
import supertest from 'supertest';
import supertestGQL, { Variables } from 'supertest-graphql';
import { ADMIN } from '~/@utils/roles';
import { TestManager, type TestOptions } from '~/@utils/tests/TestManager';
import { AppModule } from '~/app.module';
import { AppModule } from '~app-module';
import { ADMIN } from '~utils/roles';
import { TestManager, type TestOptions } from '~utils/tests/TestManager';
import { prepareTestDb } from '../../prisma/utils/functions';
import { TestGraphqlModule } from '../mocks/graphql.module';

Expand Down
5 changes: 4 additions & 1 deletion api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"$prisma-client": ["./src/_generated/prisma/client/index"],
"$prisma-graphql/*": ["./src/_generated/prisma-nestjs-graphql/*"],
"$*": ["./src/@common/*"],
"~/*": ["./src/*"],
"~utils/*": ["./src/@utils/*"],
"~env": ["./src/env.validation"],
"~app-module": ["./src/app.module"],
// "~/*": ["./src/*"],
},

"typeRoots": [
Expand Down

0 comments on commit 0d67213

Please sign in to comment.