Skip to content

Commit

Permalink
refactor: bind application to the container
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jul 27, 2019
1 parent 39ec2aa commit 2ef25b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/Ignitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,12 @@ export class Ignitor {
const rcContents = this._require(join(this._appRoot, '.adonisrc.json'), true) || {}

/**
* Setting up the application
* Setting up the application and binding it to the container as well. This makes
* it's way to the container even before the providers starts registering
* themselves.
*/
this.application = new Application(this._appRoot, ioc, rcContents, pkg)

/**
* For now we hardcode the envirnonment to web. Later this will change after
* the introduction of `console` and `test` bootstrappers within ignitor.
*/
this.application.environment = 'web'
ioc.singleton('Adonis/Core/Application', () => this)
}

/**
Expand Down Expand Up @@ -350,7 +347,7 @@ export class Ignitor {
*/
const Server = this.application.container.use('Adonis/Core/Server')
if (Server.instance) {
Server.on('close', () => {
Server.instance.on('close', () => {
this.application.isReady = false
})

Expand Down Expand Up @@ -400,6 +397,8 @@ export class Ignitor {
* new connections.
*/
public async startHttpServer (serverCallback?: CustomServerCallback) {
this.application.environment = 'web'

try {
await this.bootstrap()
await this._createHttpServer(serverCallback)
Expand Down
1 change: 1 addition & 0 deletions test/ignitor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ test.group('Ignitor', (group) => {
}))

const ignitor = new Ignitor(fs.basePath)
ignitor.application.environment = 'web'
await ignitor.bootstrap()

const config = ignitor.application.container.use('Adonis/Core/Config')
Expand Down

0 comments on commit 2ef25b5

Please sign in to comment.