12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { Configuration, App } from '@midwayjs/core';
- import * as koa from '@midwayjs/koa';
- import * as validate from '@midwayjs/validate';
- import * as info from '@midwayjs/info';
- import { join } from 'path';
- import { ReportMiddleware } from './middleware/report.middleware';
- import * as axios from '@midwayjs/axios';
- import * as redis from '@midwayjs/redis';
- import * as jwt from '@midwayjs/jwt';
- import * as i18n from '@midwayjs/i18n';
- import { CustomErrorFilter } from './filter/customError.filter';
- import { SetLocaleToCtxMiddleware } from './middleware/setLocaleToCtx.middleware';
- import * as upload from '@midwayjs/upload';
- @Configuration({
- imports: [
- koa,
- axios,
- validate,
- redis,
- jwt,
- i18n,
- upload,
- {
- component: info,
- enabledEnvironment: ['local'],
- },
- ],
- importConfigs: [join(__dirname, './config')],
- })
- export class MainConfiguration {
- @App('koa')
- app: koa.Application;
- async onReady() {
- // add middleware
- this.app.getMiddleware().insertFirst(SetLocaleToCtxMiddleware);
- this.app.useMiddleware([ReportMiddleware]);
- this.app.useFilter([CustomErrorFilter]);
- }
- }
|