{"action":"created","issue":{"url":"https://api.github.com/repos/jeffijoe/awilix/issues/94","repository_url":"https://api.github.com/repos/jeffijoe/awilix","labels_url":"https://api.github.com/repos/jeffijoe/awilix/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/jeffijoe/awilix/issues/94/comments","events_url":"https://api.github.com/repos/jeffijoe/awilix/issues/94/events","html_url":"https://github.com/jeffijoe/awilix/issues/94","id":348088580,"node_id":"MDU6SXNzdWUzNDgwODg1ODA=","number":94,"title":"Cyclic dependencies detected","user":{"login":"farhantahir","id":15313084,"node_id":"MDQ6VXNlcjE1MzEzMDg0","avatar_url":"https://avatars3.githubusercontent.com/u/15313084?v=4","gravatar_id":"","url":"https://api.github.com/users/farhantahir","html_url":"https://github.com/farhantahir","followers_url":"https://api.github.com/users/farhantahir/followers","following_url":"https://api.github.com/users/farhantahir/following{/other_user}","gists_url":"https://api.github.com/users/farhantahir/gists{/gist_id}","starred_url":"https://api.github.com/users/farhantahir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/farhantahir/subscriptions","organizations_url":"https://api.github.com/users/farhantahir/orgs","repos_url":"https://api.github.com/users/farhantahir/repos","events_url":"https://api.github.com/users/farhantahir/events{/privacy}","received_events_url":"https://api.github.com/users/farhantahir/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-08-06T21:29:30Z","updated_at":"2018-08-07T09:53:03Z","closed_at":null,"author_association":"NONE","body":"```\r\nAwilixResolutionError: Could not resolve 'user'. Cyclic dependencies detected.\r\nResolution path: registerationService -> userRepository -> user -> user\r\n```\r\n\r\nUser.js\r\n\r\n```\r\nconst mongoose = require('mongoose');\r\nconst Schema = mongoose.Schema;\r\n\r\nconst userSchema = new Schema({\r\n  name: String,\r\n  email: String,\r\n  password: String\r\n});\r\n\r\nclass UserClass {\r\n  \r\n}\r\n\r\nuserSchema.loadClass(UserClass);\r\n\r\nmodule.exports = mongoose.model('Users', userSchema);\r\n\r\n\r\n```\r\nUserRepository.js\r\n\r\n```\r\nconst BaseRepository = require('./BaseRepository');\r\n\r\nclass UserRepository extends BaseRepository {\r\n  constructor({ user }) {\r\n    this.model = user;\r\n  }\r\n  \r\n  find(filters = {}) {\r\n    return this.model.find(filters);\r\n  }\r\n}\r\n\r\nmodule.exports = UserRepository;\r\n```\r\nRegisterationService.js\r\n\r\n```\r\nclass RegisterationService {\r\n  constructor({userRepository}) {\r\n    this.userRepository = userRepository;\r\n  }\r\n\r\n  signUp() {\r\n  // testing it out\r\n    return new Promise((res, rej) => {\r\n      setTimeout(() => res(), 1000);\r\n    });\r\n  }\r\n}\r\n\r\nmodule.exports = RegisterationService;\r\n```\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/jeffijoe/awilix/issues/comments/411001590","html_url":"https://github.com/jeffijoe/awilix/issues/94#issuecomment-411001590","issue_url":"https://api.github.com/repos/jeffijoe/awilix/issues/94","id":411001590,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMTAwMTU5MA==","user":{"login":"farhantahir","id":15313084,"node_id":"MDQ6VXNlcjE1MzEzMDg0","avatar_url":"https://avatars3.githubusercontent.com/u/15313084?v=4","gravatar_id":"","url":"https://api.github.com/users/farhantahir","html_url":"https://github.com/farhantahir","followers_url":"https://api.github.com/users/farhantahir/followers","following_url":"https://api.github.com/users/farhantahir/following{/other_user}","gists_url":"https://api.github.com/users/farhantahir/gists{/gist_id}","starred_url":"https://api.github.com/users/farhantahir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/farhantahir/subscriptions","organizations_url":"https://api.github.com/users/farhantahir/orgs","repos_url":"https://api.github.com/users/farhantahir/repos","events_url":"https://api.github.com/users/farhantahir/events{/privacy}","received_events_url":"https://api.github.com/users/farhantahir/received_events","type":"User","site_admin":false},"created_at":"2018-08-07T09:53:03Z","updated_at":"2018-08-07T09:53:03Z","author_association":"NONE","body":"@jeffijoe Yeah its working now. I had put that in wrong file. Thanks a lot. \r\n\r\nJust one last question. As for express we have to require models in mostly like `app.js`. Then with this I have to always do `require('./User.js')();`. Is there any workaround instead of exporting function. \r\n\r\nThanks a lot for the help and quick response."}}
{"actor":{"display_login":"farhantahir"}}