refactor(server): standalone runtime module (#9120)

This commit is contained in:
forehalo
2024-12-13 06:27:14 +00:00
parent 4c23991047
commit 81c68032e1
18 changed files with 85 additions and 75 deletions
@@ -6,9 +6,9 @@ import type {
import { Injectable } from '@nestjs/common';
import {
Config,
getRequestResponseFromContext,
GuardProvider,
Runtime,
} from '../../base';
import { CaptchaService } from './service';
@@ -21,13 +21,13 @@ export class CaptchaGuardProvider
constructor(
private readonly captcha: CaptchaService,
private readonly config: Config
private readonly runtime: Runtime
) {
super();
}
async canActivate(context: ExecutionContext) {
if (!(await this.config.runtime.fetch('plugins.captcha/enable'))) {
if (!(await this.runtime.fetch('plugins.captcha/enable'))) {
return true;
}
@@ -5,10 +5,10 @@ import Stripe from 'stripe';
import { z } from 'zod';
import {
Config,
EventEmitter,
InternalServerError,
InvalidCheckoutParameters,
Runtime,
SubscriptionAlreadyExists,
SubscriptionPlanNotFound,
URLHelper,
@@ -56,7 +56,7 @@ export class UserSubscriptionManager extends SubscriptionManager {
constructor(
stripe: Stripe,
db: PrismaClient,
private readonly config: Config,
private readonly runtime: Runtime,
private readonly feature: FeatureManagementService,
private readonly event: EventEmitter,
private readonly url: URLHelper
@@ -617,7 +617,7 @@ export class UserSubscriptionManager extends SubscriptionManager {
{ proEarlyAccess, proSubscribed, onetime }: PriceStrategyStatus
) {
if (lookupKey.recurring === SubscriptionRecurring.Lifetime) {
return this.config.runtime.fetch('plugins.payment/showLifetimePrice');
return this.runtime.fetch('plugins.payment/showLifetimePrice');
}
if (lookupKey.variant === SubscriptionVariant.Onetime) {