import { EggAppConfig , EggAppInfo , PowerPartial , Context } from 'egg' ; import { existsSync , readFileSync } from 'fs' ; import { join } from 'path' ; export default ( appInfo ) => { const config = { } as PowerPartial < EggAppConfig > ; config . keys = appInfo . name + '_1573536988115_9104' ; config . middleware = [ ] ; config . security = { csrf : { enable : false , } , } ; config . onerror = { all ( err , ctx ) { try { ctx . app . errorManager . handleError ( 'Global Onerror Uncatched Error' , err ) ; } catch ( error ) { ctx . logger . error ( error ) ; } } , } ; const bizConfig = { sourceUrl : `https://github.com/eggjs/examples/tree/master/${ appInfo . name }` , } ; let pluginConfig = { } ; const globalConfigPath = process . env . GLOBAL_CONFIG ; if ( globalConfigPath ) { const globalConfigFilePath = join ( appInfo . baseDir , globalConfigPath ) ; if ( existsSync ( globalConfigFilePath ) ) { pluginConfig = JSON . parse ( readFileSync ( globalConfigFilePath ) . toString ( ) ) ; } } return { ... pluginConfig , ... config , ... bizConfig , } ; } ;