revert: durable of provider

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2022-08-23 21:56:41 +08:00
parent 6354adc359
commit d775fd49a4
3 changed files with 97 additions and 106 deletions

View File

@@ -1,4 +1,5 @@
import { AxiosRequestConfig } from 'axios' /* eslint-disable @typescript-eslint/consistent-type-imports */
import type { AxiosRequestConfig } from 'axios'
import cluster from 'cluster' import cluster from 'cluster'
import { argv } from 'zx-cjs' import { argv } from 'zx-cjs'

View File

@@ -52,11 +52,7 @@ import { HelperModule } from './processors/helper/helper.module'
import { LoggerModule } from './processors/logger/logger.module' import { LoggerModule } from './processors/logger/logger.module'
import { RedisModule } from './processors/redis/redis.module' import { RedisModule } from './processors/redis/redis.module'
@Module({}) @Module({
export class AppModule {
static register(isInit: boolean): DynamicModule {
return {
module: AppModule,
imports: [ imports: [
LoggerModule, LoggerModule,
DatabaseModule, DatabaseModule,
@@ -74,7 +70,7 @@ export class AppModule {
FeedModule, FeedModule,
FileModule, FileModule,
HealthModule, HealthModule,
!isInit && InitModule,
LinkModule, LinkModule,
MarkdownModule, MarkdownModule,
NoteModule, NoteModule,
@@ -100,7 +96,7 @@ export class AppModule {
GatewayModule, GatewayModule,
HelperModule, HelperModule,
isDev ? DebugModule : undefined, isDev && DebugModule,
].filter(Boolean) as Type<NestModule>[], ].filter(Boolean) as Type<NestModule>[],
controllers: [AppController], controllers: [AppController],
providers: [ providers: [
@@ -143,6 +139,12 @@ export class AppModule {
useClass: RolesGuard, useClass: RolesGuard,
}, },
], ],
})
export class AppModule {
static register(isInit: boolean): DynamicModule {
return {
module: AppModule,
imports: [!isInit && InitModule].filter(Boolean) as Type<NestModule>[],
} }
} }
} }

View File

@@ -1,16 +1,8 @@
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { import { BadRequestException, Injectable, Logger } from '@nestjs/common'
BadRequestException,
Inject,
Injectable,
Logger,
Scope,
} from '@nestjs/common'
import { REQUEST } from '@nestjs/core'
import { ConfigsService } from '~/modules/configs/configs.service' import { ConfigsService } from '~/modules/configs/configs.service'
import { Request } from '~/types/request'
import { deepCloneWithFunction } from '~/utils' import { deepCloneWithFunction } from '~/utils'
import { safeEval } from '~/utils/safe-eval.util' import { safeEval } from '~/utils/safe-eval.util'
@@ -20,15 +12,11 @@ const RegMap = {
'?': /^\?\??(.*?)\??\?$/g, '?': /^\?\??(.*?)\??\?$/g,
} as const } as const
@Injectable({ @Injectable({})
scope: Scope.REQUEST,
durable: true,
})
export class TextMacroService { export class TextMacroService {
private readonly logger: Logger private readonly logger: Logger
constructor( constructor(
private readonly configService: ConfigsService, private readonly configService: ConfigsService, // @Inject(REQUEST) private readonly request: Request,
@Inject(REQUEST) private readonly request: Request,
) { ) {
this.logger = new Logger(TextMacroService.name) this.logger = new Logger(TextMacroService.name)
} }
@@ -86,9 +74,9 @@ export class TextMacroService {
// time utils // time utils
dayjs: deepCloneWithFunction(dayjs), dayjs: deepCloneWithFunction(dayjs),
fromNow: (time: Date | string) => dayjs(time).fromNow(), fromNow: (time: Date | string) => dayjs(time).fromNow(),
onlyMe: (text: string) => { // onlyMe: (text: string) => {
return this.request.isMaster ? text : '' // return this.request.isMaster ? text : ''
}, // },
// typography // typography
center: (text: string) => { center: (text: string) => {