import { saveModule } from '@midwayjs/decorator' ; import { Connection , ConnectionOptions } from 'typeorm' ; export const ORM_HOOK_KEY = '__orm_hook_for_configuration__' ; export interface OrmConnectionHook { beforeCreate ? ( opts ? ) : Promise < ConnectionOptions > ; afterCreate ? ( conn ? , opts ? ) : Promise < Connection > ; beforeClose ? ( conn ? , connectionName ? ) : Promise < Connection > ; afterClose ? ( conn ? ) : Promise < Connection > ; } export function OrmHook ( ) { return function ( target ) { if ( typeof target === 'function' ) { saveModule ( ORM_HOOK_KEY , target ) ; } else { saveModule ( ORM_HOOK_KEY , ( target as any ) . constructor ) ; } } ; }