mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 11:36:25 +08:00
refactor(server): config system (#11081)
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import './config';
|
||||
|
||||
import { join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import type { ApolloDriverConfig } from '@nestjs/apollo';
|
||||
import { ApolloDriver } from '@nestjs/apollo';
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { Request, Response } from 'express';
|
||||
import type { Request, Response } from 'express';
|
||||
|
||||
import { Config } from '../config';
|
||||
import { mapAnyError } from '../nestjs/exception';
|
||||
@@ -26,18 +25,17 @@ export type GraphqlContext = {
|
||||
driver: ApolloDriver,
|
||||
useFactory: (config: Config) => {
|
||||
return {
|
||||
...config.graphql,
|
||||
path: `${config.server.path}/graphql`,
|
||||
...config.graphql.apolloDriverConfig,
|
||||
autoSchemaFile: join(
|
||||
env.projectRoot,
|
||||
env.testing
|
||||
? './node_modules/.cache/schema.gql'
|
||||
: './src/schema.gql'
|
||||
),
|
||||
path: '/graphql',
|
||||
csrfPrevention: {
|
||||
requestHeaders: ['content-type'],
|
||||
},
|
||||
autoSchemaFile: join(
|
||||
fileURLToPath(import.meta.url),
|
||||
config.node.dev
|
||||
? '../../../schema.gql'
|
||||
: '../../../../node_modules/.cache/schema.gql'
|
||||
),
|
||||
sortSchema: true,
|
||||
context: ({
|
||||
req,
|
||||
res,
|
||||
@@ -55,7 +53,7 @@ export type GraphqlContext = {
|
||||
|
||||
// @ts-expect-error allow assign
|
||||
formattedError.extensions = ufe.toJSON();
|
||||
if (config.affine.canary) {
|
||||
if (env.namespaces.canary) {
|
||||
formattedError.extensions.stacktrace = ufe.stacktrace;
|
||||
}
|
||||
return formattedError;
|
||||
|
||||
Reference in New Issue
Block a user