Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container.registerValue is not a function in booking-service/src/index.js #11

Open
Kaushalop opened this issue Jun 14, 2018 · 3 comments

Comments

@Kaushalop
Copy link

Kaushalop commented Jun 14, 2018

Running npm start

I get the error : container.registerValue is not a function when i add a catch the Promise reject in src/index.js as below

mediator.on('di.ready', (container) => {
  repository.connect(container)
    .then(repo => {
      console.log('Connected. Starting Server')
      container.registerValue({repo})
      return server.start(container)
    })
    .then(app => {
      console.log(`Server started succesfully, running on port: ${container.cradle.serverSettings.port}.`)
      app.on('close', () => {
        container.resolve('repo').disconnect()
      })
    })
    .catch((err) => {
      console.log('Promise errorrr!');
      console.log(err);
    })
})

I realise that the container that is created with 'awilix' does not contain this function normally nor does the di.proto.js create this function, am i missing something here ?

@Kaushalop
Copy link
Author

Since the version got upgraded for 'awilix' to 3.0.8 from 2.2.2 in this project, I believe the function might have been deprecated.

So, i made a change as per the latest API as well but does not work and the it throws out the log
Change :
container.register('repo', asValue({repo}))

Log :
Error: The server must be started with a connected repository

@Kaushalop Kaushalop reopened this Jun 14, 2018
@duyleomessi
Copy link

I have the same problem, did you solve it??

@ramasubbareddy1224
Copy link

do following imports in src/index.js

const awilix = require('awilix')
const { asValue} = awilix


container.register({ repo: asValue(repo) })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants