12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import { Configuration, App, Inject } from '@midwayjs/core';
- import * as koa from '@midwayjs/koa';
- import * as validate from '@midwayjs/validate';
- import * as info from '@midwayjs/info';
- import * as swagger from '@midwayjs/swagger';
- import * as jwt from '@midwayjs/jwt';
- import * as redis from '@midwayjs/redis';
- import * as axios from '@midwayjs/axios';
- // import { IMidwayContainer } from '@midwayjs/core';
- import { join } from 'path';
- // freemidway组件项目
- import * as FreeFrame from 'free-midway-component';
- // import { FrameworkErrorEnum, ServiceError } from 'free-midway-component';
- // 控制器执行前函数
- import { CheckTokenMiddleware } from './middleware/checkToken.middleware';
- // 请求成功,失败提示
- // const axiosResponse = response => {
- // if (response.status === 0) return response.data;
- // else {
- // console.log(JSON.stringify(response));
- // throw new ServiceError('请求失败', FrameworkErrorEnum.SERVICE_FAULT);
- // }
- // };
- // const axiosError = error => {
- // return Promise.reject(error);
- // };
- @Configuration({
- imports: [
- FreeFrame,
- validate,
- jwt,
- redis,
- axios,
- swagger,
- {
- component: info,
- enabledEnvironment: ['local'],
- },
- ],
- importConfigs: [join(__dirname, './config')],
- })
- export class ContainerLifeCycle {
- @App()
- app: koa.Application;
- @Inject()
- bullFramework: bull.Framework;
- async onReady() {
- this.app.getMiddleware().insertFirst(CheckTokenMiddleware);
- }
- }
|