fix(server): node imports order (#5583)

This commit is contained in:
liuyi
2024-01-14 05:47:56 +00:00
parent 18907ebe57
commit 4c49b62ab7
16 changed files with 109 additions and 101 deletions
+2 -38
View File
@@ -2,45 +2,9 @@
// keep the config import at the top
// eslint-disable-next-line simple-import-sort/imports
import './prelude';
import { createApp } from './app';
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 { AppModule } from './app';
import { RedisIoAdapter } from './fundamentals';
import { CacheRedis } from './fundamentals/cache/redis';
import { ExceptionLogger } from './middleware/exception-logger';
import { serverTimingAndCache } from './middleware/timing';
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
cors: true,
rawBody: true,
bodyParser: true,
logger: AFFiNE.affine.stable ? ['log'] : ['verbose'],
});
app.use(serverTimingAndCache);
app.use(
graphqlUploadExpress({
// TODO: dynamic limit by quota
maxFileSize: 100 * 1024 * 1024,
maxFiles: 5,
})
);
app.useGlobalFilters(new ExceptionLogger());
app.use(cookieParser());
if (AFFiNE.redis.enabled) {
const redis = app.get(CacheRedis, { strict: false });
const redisIoAdapter = new RedisIoAdapter(app);
await redisIoAdapter.connectToRedis(redis);
app.useWebSocketAdapter(redisIoAdapter);
}
const app = await createApp();
await app.listen(AFFiNE.port, AFFiNE.host);
console.log(