-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.ts
38 lines (27 loc) · 1022 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { join } from 'path'
import { NestFactory } from '@nestjs/core'
import { NestExpressApplication } from '@nestjs/platform-express'
import cookieParser from 'cookie-parser'
import compression from 'compression'
import App from './app.module'
import { StandardRespInterceptor } from './common/interceptor/standardResp.interceptor'
import { ErrorFilter } from './common/filter/errorResp.filter'
import Config from './config'
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(App);
app.use(cookieParser());
// 是否开启跨域配置
app.enableCors();
// 静态资源配置
app.useStaticAssets(join(__dirname, 'uploads'), {
prefix: '/static'
})
// 全局异常处理
app.useGlobalFilters(new ErrorFilter())
// 处理全局数据返回
app.useGlobalInterceptors(new StandardRespInterceptor())
// 开启Gzip压缩请求
app.use(compression())
await app.listen(Config.serverConfig.port);
}
bootstrap()