mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
close CLOUD-233 #### PR Dependency Tree * **PR #12950** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for configuring multiple server hosts across backend and frontend settings. * Enhanced deployment and Helm chart configuration to allow specifying multiple ingress hosts. * Updated admin and configuration interfaces to display and manage multiple server hosts. * **Improvements** * Improved URL generation, OAuth, and worker service logic to dynamically handle requests from multiple hosts. * Enhanced captcha verification to support multiple allowed hostnames. * Updated frontend logic for platform-specific server base URLs and allowed origins, including Apple app domains. * Expanded test coverage for multi-host scenarios. * **Bug Fixes** * Corrected backend logic to consistently use dynamic base URLs and origins based on request host context. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import type { NestExpressApplication } from '@nestjs/platform-express';
|
|
import cookieParser from 'cookie-parser';
|
|
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.mjs';
|
|
|
|
import {
|
|
AFFiNELogger,
|
|
CacheInterceptor,
|
|
CloudThrottlerGuard,
|
|
Config,
|
|
GlobalExceptionFilter,
|
|
URLHelper,
|
|
} from './base';
|
|
import { SocketIoAdapter } from './base/websocket';
|
|
import { AuthGuard } from './core/auth';
|
|
import { serverTimingAndCache } from './middleware/timing';
|
|
|
|
const OneMB = 1024 * 1024;
|
|
|
|
export async function run() {
|
|
const { AppModule } = await import('./app.module');
|
|
|
|
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
|
cors: true,
|
|
rawBody: true,
|
|
bodyParser: true,
|
|
bufferLogs: true,
|
|
});
|
|
|
|
app.useBodyParser('raw', { limit: 100 * OneMB });
|
|
|
|
const logger = app.get(AFFiNELogger);
|
|
app.useLogger(logger);
|
|
const config = app.get(Config);
|
|
|
|
if (config.server.path) {
|
|
app.setGlobalPrefix(config.server.path);
|
|
}
|
|
|
|
app.use(serverTimingAndCache);
|
|
|
|
app.use(
|
|
graphqlUploadExpress({
|
|
maxFileSize: 100 * OneMB,
|
|
maxFiles: 32,
|
|
})
|
|
);
|
|
|
|
app.useGlobalGuards(app.get(AuthGuard), app.get(CloudThrottlerGuard));
|
|
app.useGlobalInterceptors(app.get(CacheInterceptor));
|
|
app.useGlobalFilters(new GlobalExceptionFilter(app.getHttpAdapter()));
|
|
app.use(cookieParser());
|
|
// only enable shutdown hooks in production
|
|
// https://docs.nestjs.com/fundamentals/lifecycle-events#application-shutdown
|
|
if (env.prod) {
|
|
app.enableShutdownHooks();
|
|
}
|
|
|
|
const adapter = new SocketIoAdapter(app);
|
|
app.useWebSocketAdapter(adapter);
|
|
|
|
const url = app.get(URLHelper);
|
|
const listeningHost = '0.0.0.0';
|
|
|
|
await app.listen(config.server.port, listeningHost);
|
|
|
|
logger.log(`AFFiNE Server is running in [${env.DEPLOYMENT_TYPE}] mode`);
|
|
logger.log(`Listening on http://${listeningHost}:${config.server.port}`);
|
|
logger.log(`And the public server should be recognized as ${url.baseUrl}`);
|
|
}
|