crizstian / cinema-microservice

Example of a cinema microservice
1.76k stars 656 forks source link

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

Open Kaushalop opened 6 years ago

Kaushalop commented 6 years ago

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 commented 6 years ago

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

duyleomessi commented 4 years ago

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

ramasubbareddy1224 commented 4 years ago

do following imports in src/index.js

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


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