import { App , Configuration } from '@midwayjs/decorator' ; import { ILifeCycle , IMidwayContainer } from '@midwayjs/core' ; import * as swagger from '@midwayjs/swagger' ; import * as orm from '@midwayjs/orm' ; import * as bull from 'midway-bull' ; import * as cache from '@midwayjs/cache' ; import { IMidwayWebApplication } from '@midwayjs/web' ; import { AdminSysTaskService } from './service/admin/sys/task' ; import * as moment from 'moment' ; import axios from 'axios' ; @ Configuration ( { conflictCheck : true , imports : [ orm , bull , cache , { component : swagger , enabledEnvironment : [ 'local' ] , } , ] , } ) export class ContainerLifeCycle implements ILifeCycle { @ App ( ) app : IMidwayWebApplication ; async onReady ( container ) { this . app . getApplicationContext ( ) . registerObject ( 'httpclient' , axios ) ; const taskService = await container . getAsync ( AdminSysTaskService ) ; await taskService . initTask ( ) ; Date . prototype . toJSON = function ( ) { return moment ( this ) . format ( 'YYYY-MM-DD HH:mm:ss' ) ; } ; } }