This is the error that I got. It looks like routes with the same path are added more than once and is rejected by Hapi. I'm not sure if I'm doing something wrong. Please help. Thanks
Error: New route /teams conflicts with existing /teams
at Object.exports.assert (/Users/dlo/hapi-sequelize-test/node_modules/hapi/node_modules/hoek/lib/index.js:736:11)
at internals.Segment.add (/Users/dlo/hapi-sequelize-test/node_modules/hapi/node_modules/call/lib/segment.js:51:14)
at internals.Router.add (/Users/dlo/hapi-sequelize-test/node_modules/hapi/node_modules/call/lib/index.js:62:26)
at internals.Connection._addRoute (/Users/dlo/hapi-sequelize-test/node_modules/hapi/lib/connection.js:416:37)
at internals.Connection._route (/Users/dlo/hapi-sequelize-test/node_modules/hapi/lib/connection.js:403:18)
at internals.Plugin._apply (/Users/dlo/hapi-sequelize-test/node_modules/hapi/lib/plugin.js:588:14)
at internals.Plugin.route (/Users/dlo/hapi-sequelize-test/node_modules/hapi/lib/plugin.js:558:10)
at Object.exports.list (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/crud.js:220:10)
at Object.keys.forEach.method (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/crud.js:81:20)
at Array.forEach (native)
at createAll (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/crud.js:80:24)
at exports.default (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/crud.js:181:5)
at Object.keys.forEach.modelName (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/index.js:117:24)
at Array.forEach (native)
at Object.register (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/index.js:115:23)
at Object.target [as register] (/Users/dlo/hapi-sequelize-test/node_modules/hapi/node_modules/joi/lib/object.js:77:34)```
Hello, I have these two associations defined
`Team.belongsToMany(Project, {through: 'TeamProjects})`
`Project.belongsToMany(Team, {through: 'TeamProjects})`
This is the error that I got. It looks like routes with the same path are added more than once and is rejected by Hapi. I'm not sure if I'm doing something wrong. Please help. Thanks
```
Error: New route /teams conflicts with existing /teams
at Object.exports.assert (/Users/dlo/hapi-sequelize-test/node_modules/hapi/node_modules/hoek/lib/index.js:736:11)
at internals.Segment.add (/Users/dlo/hapi-sequelize-test/node_modules/hapi/node_modules/call/lib/segment.js:51:14)
at internals.Router.add (/Users/dlo/hapi-sequelize-test/node_modules/hapi/node_modules/call/lib/index.js:62:26)
at internals.Connection._addRoute (/Users/dlo/hapi-sequelize-test/node_modules/hapi/lib/connection.js:416:37)
at internals.Connection._route (/Users/dlo/hapi-sequelize-test/node_modules/hapi/lib/connection.js:403:18)
at internals.Plugin._apply (/Users/dlo/hapi-sequelize-test/node_modules/hapi/lib/plugin.js:588:14)
at internals.Plugin.route (/Users/dlo/hapi-sequelize-test/node_modules/hapi/lib/plugin.js:558:10)
at Object.exports.list (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/crud.js:220:10)
at Object.keys.forEach.method (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/crud.js:81:20)
at Array.forEach (native)
at createAll (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/crud.js:80:24)
at exports.default (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/crud.js:181:5)
at Object.keys.forEach.modelName (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/index.js:117:24)
at Array.forEach (native)
at Object.register (/Users/dlo/hapi-sequelize-test/node_modules/hapi-sequelize-crud/build/index.js:115:23)
at Object.target [as register] (/Users/dlo/hapi-sequelize-test/node_modules/hapi/node_modules/joi/lib/object.js:77:34)```
The problem was that the forEach loop was processing join table models as well (e.g. TeamPlayers) which would cause duplicate CRUD creation for models. This seems to fix the issue.
@joeybaker I just saw your commit https://github.com/mdibaiee/hapi-sequelize-crud/commit/83eadf0929a2506541e34b4a6f73d46bfa2404d3 and reverted my commit to respect yours.
The problem was that the forEach loop was processing join table models as well (e.g. `TeamPlayers`) which would cause duplicate CRUD creation for models. This seems to fix the issue.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Hello, I have these two associations defined
Team.belongsToMany(Project, {through: 'TeamProjects})Project.belongsToMany(Team, {through: 'TeamProjects})This is the error that I got. It looks like routes with the same path are added more than once and is rejected by Hapi. I'm not sure if I'm doing something wrong. Please help. Thanks
Could you please post your entire models definitions and plugin registration code?
Sure, here they are.
team.js
player.js
index.js
package.json
@lmd2692 You are right, it was a bug, I published the new version as
hapi-sequelize-crud@2.9.2.@joeybaker I just saw your commit https://github.com/mdibaiee/hapi-sequelize-crud/commit/83eadf0929a2506541e34b4a6f73d46bfa2404d3 and reverted my commit to respect yours.
The problem was that the forEach loop was processing join table models as well (e.g.
TeamPlayers) which would cause duplicate CRUD creation for models. This seems to fix the issue.