fix: lint
This commit is contained in:
@@ -450,6 +450,10 @@ export class ServerlessService implements OnModuleInit {
|
||||
'vm',
|
||||
]
|
||||
|
||||
for (const lib of [...bannedLibs]) {
|
||||
bannedLibs.push(`node:${lib}`)
|
||||
}
|
||||
|
||||
if (bannedLibs.includes(id)) {
|
||||
throw new Error(`cannot require ${id}`)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
import type { ModuleMetadata } from '@nestjs/common'
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
import type {
|
||||
BeAnObject,
|
||||
ReturnModelType,
|
||||
} from '@typegoose/typegoose/lib/types'
|
||||
|
||||
import { APP_INTERCEPTOR } from '@nestjs/core'
|
||||
|
||||
import { HttpCacheInterceptor } from '~/common/interceptors/cache.interceptor'
|
||||
@@ -9,12 +16,6 @@ import { getModelToken } from '~/transformers/model.transformer'
|
||||
import { dbHelper } from './db-mock.helper'
|
||||
import { redisHelper } from './redis-mock.helper'
|
||||
import { setupE2EApp } from './setup-e2e'
|
||||
import type {
|
||||
BeAnObject,
|
||||
ReturnModelType,
|
||||
} from '@typegoose/typegoose/lib/types'
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
import type { ModuleMetadata } from '@nestjs/common'
|
||||
|
||||
type ClassType = new (...args: any[]) => any
|
||||
|
||||
@@ -63,8 +64,9 @@ export const createE2EApp = (module: ModuleMetadata & E2EAppMetaData) => {
|
||||
provide: APP_INTERCEPTOR,
|
||||
useClass: ResponseInterceptor, // 1
|
||||
},
|
||||
{ provide: token, useValue: CacheService },
|
||||
)
|
||||
|
||||
nestModule.providers.push({ provide: token, useValue: CacheService })
|
||||
const modelMap = new Map() as ModelMap
|
||||
if (models) {
|
||||
models.forEach((model) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Global, Module } from '@nestjs/common'
|
||||
import type { Provider } from '@nestjs/common'
|
||||
|
||||
import { Global, Module } from '@nestjs/common'
|
||||
|
||||
export const createMockGlobalModule = (providers: Provider[]) => {
|
||||
@Global()
|
||||
@Module({
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { MongoMemoryServer } from 'mongodb-memory-server'
|
||||
import mongoose from 'mongoose'
|
||||
import { getModelForClass } from '@typegoose/typegoose'
|
||||
import type {
|
||||
AnyParamConstructor,
|
||||
BeAnObject,
|
||||
@@ -8,6 +7,8 @@ import type {
|
||||
ReturnModelType,
|
||||
} from '@typegoose/typegoose/lib/types'
|
||||
|
||||
import { getModelForClass } from '@typegoose/typegoose'
|
||||
|
||||
let mongod: MongoMemoryServer
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import IORedis from 'ioredis'
|
||||
import RedisMemoryServer from 'redis-memory-server'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import type { Redis } from 'ioredis'
|
||||
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
|
||||
export class MockCacheService {
|
||||
private client: Redis
|
||||
constructor(port: number, host: string) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import type { ModuleMetadata } from '@nestjs/common'
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
|
||||
import { ValidationPipe } from '@nestjs/common'
|
||||
import { Test, TestingModule } from '@nestjs/testing'
|
||||
|
||||
import { fastifyApp } from '~/common/adapters/fastify.adapter'
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
import type { ModuleMetadata } from '@nestjs/common'
|
||||
|
||||
export const setupE2EApp = async (module: TestingModule | ModuleMetadata) => {
|
||||
let nextModule: TestingModule
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UseGuards, applyDecorators } from '@nestjs/common'
|
||||
import { applyDecorators, UseGuards } from '@nestjs/common'
|
||||
|
||||
import { AuthTestingGuard } from '../guard/auth.guard'
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { UnauthorizedException } from '@nestjs/common'
|
||||
import { authJWTToken } from '../constants/token'
|
||||
import type { ExecutionContext } from '@nestjs/common'
|
||||
import type { UserModel } from '~/modules/user/user.model'
|
||||
|
||||
import { UnauthorizedException } from '@nestjs/common'
|
||||
|
||||
import { authJWTToken } from '../constants/token'
|
||||
|
||||
export const mockUser1: UserModel = {
|
||||
id: '1',
|
||||
name: 'John Doe',
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
|
||||
import { Test } from '@nestjs/testing'
|
||||
|
||||
import { AppController } from '~/app.controller'
|
||||
@@ -5,7 +7,6 @@ import { fastifyApp } from '~/common/adapters/fastify.adapter'
|
||||
import { OptionModel } from '~/modules/configs/configs.model'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { getModelToken } from '~/transformers/model.transformer'
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: NestFastifyApplication
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { vi } from 'vitest'
|
||||
|
||||
import { Test } from '@nestjs/testing'
|
||||
import { configProvider } from '@/mock/modules/config.mock'
|
||||
import { Test } from '@nestjs/testing'
|
||||
|
||||
import { AuthService } from '~/modules/auth/auth.service'
|
||||
import { UserModel } from '~/modules/user/user.model'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { redisHelper } from 'test/helper/redis-mock.helper'
|
||||
import { vi } from 'vitest'
|
||||
import type { MockCacheService } from 'test/helper/redis-mock.helper'
|
||||
|
||||
import { UnprocessableEntityException } from '@nestjs/common'
|
||||
import { Test } from '@nestjs/testing'
|
||||
@@ -16,7 +17,6 @@ import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { SubPubBridgeService } from '~/processors/redis/subpub.service'
|
||||
import { getModelToken } from '~/transformers/model.transformer'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import type { MockCacheService } from 'test/helper/redis-mock.helper'
|
||||
|
||||
describe('Test ConfigsService', () => {
|
||||
let service: ConfigsService
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import {
|
||||
Encrypt,
|
||||
decryptObject,
|
||||
Encrypt,
|
||||
encryptObject,
|
||||
encryptProperty,
|
||||
isEncryptProperty,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { gatewayProviders } from 'test/mock/modules/gateway.mock'
|
||||
import { userProvider } from 'test/mock/modules/user.mock'
|
||||
import { emailProvider } from 'test/mock/processors/email.mock'
|
||||
import { eventEmitterProvider } from 'test/mock/processors/event.mock'
|
||||
import type { ReturnModelType } from '@typegoose/typegoose'
|
||||
|
||||
import { ExtendedValidationPipe } from '~/common/pipes/validation.pipe'
|
||||
import { VALIDATION_PIPE_INJECTION } from '~/constants/system.constant'
|
||||
@@ -15,7 +16,6 @@ import {
|
||||
import { LinkModel, LinkState } from '~/modules/link/link.model'
|
||||
import { LinkService } from '~/modules/link/link.service'
|
||||
import { HttpService } from '~/processors/helper/helper.http.service'
|
||||
import type { ReturnModelType } from '@typegoose/typegoose'
|
||||
|
||||
describe('Test LinkController(E2E)', () => {
|
||||
const proxy = createE2EApp({
|
||||
|
||||
@@ -78,7 +78,7 @@ describe('test serverless function service', () => {
|
||||
Object.assign<SnippetModel, Partial<SnippetModel>>(model, {
|
||||
type: SnippetType.Function,
|
||||
raw: async function handler(context, require) {
|
||||
return (await require('node:path')).join('1', '1')
|
||||
return (await require('path')).join('1', '1')
|
||||
}.toString(),
|
||||
})
|
||||
const data = await service.injectContextIntoServerlessFunctionAndCall(
|
||||
@@ -108,7 +108,7 @@ describe('test serverless function service', () => {
|
||||
Object.assign<SnippetModel, Partial<SnippetModel>>(model, {
|
||||
type: SnippetType.Function,
|
||||
raw: async function handler(context, require) {
|
||||
return await require('node:os')
|
||||
return await require('os')
|
||||
}.toString(),
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { createE2EApp } from 'test/helper/create-e2e-app'
|
||||
import { authPassHeader } from 'test/mock/guard/auth.guard'
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
import type { ReturnModelType } from '@typegoose/typegoose'
|
||||
|
||||
import { ServerlessService } from '~/modules/serverless/serverless.service'
|
||||
import { SnippetController } from '~/modules/snippet/snippet.controller'
|
||||
@@ -7,8 +9,6 @@ import { SnippetModel, SnippetType } from '~/modules/snippet/snippet.model'
|
||||
import { SnippetService } from '~/modules/snippet/snippet.service'
|
||||
import { DatabaseService } from '~/processors/database/database.service'
|
||||
import { EventManagerService } from '~/processors/helper/helper.event.service'
|
||||
import type { ReturnModelType } from '@typegoose/typegoose'
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
|
||||
describe('test /snippets', () => {
|
||||
let app: NestFastifyApplication
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { dbHelper } from 'test/helper/db-mock.helper'
|
||||
import { redisHelper } from 'test/helper/redis-mock.helper'
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
|
||||
import { Test } from '@nestjs/testing'
|
||||
import { createMockGlobalModule } from '@/helper/create-mock-global-module'
|
||||
import { configProvider } from '@/mock/modules/config.mock'
|
||||
import { Test } from '@nestjs/testing'
|
||||
|
||||
import { fastifyApp } from '~/common/adapters/fastify.adapter'
|
||||
import { AuthService } from '~/modules/auth/auth.service'
|
||||
@@ -12,7 +13,6 @@ import { UserController } from '~/modules/user/user.controller'
|
||||
import { UserModel } from '~/modules/user/user.model'
|
||||
import { UserService } from '~/modules/user/user.service'
|
||||
import { getModelToken } from '~/transformers/model.transformer'
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: NestFastifyApplication
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Test } from '@nestjs/testing'
|
||||
import { createMockGlobalModule } from '@/helper/create-mock-global-module'
|
||||
import { configProvider } from '@/mock/modules/config.mock'
|
||||
import { Test } from '@nestjs/testing'
|
||||
|
||||
import { AuthService } from '~/modules/auth/auth.service'
|
||||
import { AuthnService } from '~/modules/authn/authn.service'
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { IsDefined, IsNumber } from 'class-validator'
|
||||
import { eventEmitterProvider } from 'test/mock/processors/event.mock'
|
||||
import type { ReturnModelType } from '@typegoose/typegoose'
|
||||
|
||||
import { modelOptions, prop } from '@typegoose/typegoose'
|
||||
import { createE2EApp } from '@/helper/create-e2e-app'
|
||||
import { authPassHeader } from '@/mock/guard/auth.guard'
|
||||
import { modelOptions, prop } from '@typegoose/typegoose'
|
||||
|
||||
import { BaseModel } from '~/shared/model/base.model'
|
||||
import { BaseCrudFactory } from '~/transformers/crud-factor.transformer'
|
||||
import type { ReturnModelType } from '@typegoose/typegoose'
|
||||
|
||||
@modelOptions({
|
||||
options: {
|
||||
|
||||
Reference in New Issue
Block a user