mirror of
https://github.com/certd/certd.git
synced 2026-05-16 05:07:32 +08:00
🔱: [server] sync upgrade with 21 commits [trident-sync]
Update README.md
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import * as validateComp from '@midwayjs/validate';
|
||||
import * as productionConfig from './config/config.production';
|
||||
import * as previewConfig from './config/config.preview';
|
||||
import * as defaultConfig from './config/config.default';
|
||||
import { Configuration, App } from '@midwayjs/decorator';
|
||||
import * as koa from '@midwayjs/koa';
|
||||
import * as bodyParser from 'koa-bodyparser';
|
||||
import * as orm from '@midwayjs/typeorm';
|
||||
import * as cache from '@midwayjs/cache';
|
||||
import * as cors from '@koa/cors';
|
||||
import { join } from 'path';
|
||||
import * as flyway from 'midway-flyway-js';
|
||||
import {ReportMiddleware} from "./middleware/report";
|
||||
import {GlobalExceptionMiddleware} from "./middleware/global-exception";
|
||||
import {PreviewMiddleware} from "./middleware/preview";
|
||||
import {AuthorityMiddleware} from "./middleware/authority";
|
||||
@Configuration({
|
||||
imports: [koa, orm, cache, flyway,validateComp],
|
||||
importConfigs: [
|
||||
{
|
||||
default: defaultConfig,
|
||||
preview: previewConfig,
|
||||
production: productionConfig,
|
||||
},
|
||||
],
|
||||
})
|
||||
export class ContainerConfiguration {}
|
||||
@Configuration({
|
||||
conflictCheck: true,
|
||||
importConfigs: [join(__dirname, './config')],
|
||||
})
|
||||
export class ContainerLifeCycle {
|
||||
@App()
|
||||
app: koa.Application;
|
||||
|
||||
async onReady() {
|
||||
//跨域
|
||||
this.app.use(
|
||||
cors({
|
||||
origin: '*',
|
||||
})
|
||||
);
|
||||
// bodyparser options see https://github.com/koajs/bodyparser
|
||||
this.app.use(bodyParser());
|
||||
//请求日志打印
|
||||
|
||||
this.app.useMiddleware([
|
||||
|
||||
ReportMiddleware,
|
||||
//统一异常处理
|
||||
GlobalExceptionMiddleware,
|
||||
//预览模式限制修改id<1000的数据
|
||||
PreviewMiddleware,
|
||||
//授权处理
|
||||
AuthorityMiddleware
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user