diff --git a/index.ts b/index.ts index 348140f..0c2fa13 100644 --- a/index.ts +++ b/index.ts @@ -7,7 +7,5 @@ * file that was distributed with this source code. */ -export * from 'src/Ignite' - export * from 'src/Modules/HttpRoute' export * from 'src/Modules/HttpServer' diff --git a/package.json b/package.json index 07374c0..b067f9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/core", - "version": "1.0.0", + "version": "1.0.1", "description": "", "license": "MIT", "author": "João Lenon ", diff --git a/src/Factories/AthennaFactory.ts b/src/Factories/AthennaFactory.ts index 7d9064a..25c0d62 100644 --- a/src/Factories/AthennaFactory.ts +++ b/src/Factories/AthennaFactory.ts @@ -17,52 +17,41 @@ export class AthennaFactory { private static logger: Logger private static extension: '.js' | '.ts' - private static bootProviders() { + private static getProviders() { const providers = Config.get('app.providers') + const providersNormalized: any[] = [] providers.forEach(Provider => { if (Is.Class(Provider)) { - AthennaFactory.logger.log(`Booting ${Provider.name}`) + providersNormalized.push(Provider) - return new Provider().boot() + return } if (Is.Object(Provider) && !Provider.default) { const firstProviderKey = Object.keys(Provider)[0] - AthennaFactory.logger.log(`Booting ${firstProviderKey}`) - return new Provider[firstProviderKey]().boot() - } + providersNormalized.push(Provider[firstProviderKey]) - AthennaFactory.logger.log(`Booting ${Provider.default.name}`) + return + } - // eslint-disable-next-line new-cap - return new Provider.default().boot() + providersNormalized.push(Provider.default()) }) - } - - private static registerProviders() { - const providers = Config.get('app.providers') - - providers.forEach(Provider => { - if (Is.Class(Provider)) { - AthennaFactory.logger.log(`Registering ${Provider.name}`) - - return new Provider().register() - } - if (Is.Object(Provider) && !Provider.default) { - const firstProviderKey = Object.keys(Provider)[0] - AthennaFactory.logger.log(`Registering ${firstProviderKey}`) + providersNormalized.forEach(Provider => + AthennaFactory.logger.log(`Registering ${Provider.name}`), + ) - return new Provider[firstProviderKey]().register() - } + return providersNormalized + } - AthennaFactory.logger.log(`Registering ${Provider.default.name}`) + private static bootProviders(providers: any[]) { + providers.forEach(Provider => new Provider().boot()) + } - // eslint-disable-next-line new-cap - return new Provider.default().register() - }) + private static registerProviders(providers: any[]) { + providers.forEach(Provider => new Provider().register()) } private static preloadFiles() { @@ -86,8 +75,6 @@ export class AthennaFactory { secConfig.load(Path.config(`app${AthennaFactory.extension}`)) process.env.NODE_ENV = SecConfig.get('app.environment') - console.log(process.env.NODE_ENV) - resolveEnvFile() secConfig.load(Path.config(`app${AthennaFactory.extension}`)) @@ -99,8 +86,10 @@ export class AthennaFactory { }, }) - AthennaFactory.registerProviders() - AthennaFactory.bootProviders() + const providers = AthennaFactory.getProviders() + + AthennaFactory.registerProviders(providers) + AthennaFactory.bootProviders(providers) AthennaFactory.preloadFiles() }