{"action":"created","issue":{"url":"https://api.github.com/repos/strapi/strapi/issues/163","repository_url":"https://api.github.com/repos/strapi/strapi","labels_url":"https://api.github.com/repos/strapi/strapi/issues/163/labels{/name}","comments_url":"https://api.github.com/repos/strapi/strapi/issues/163/comments","events_url":"https://api.github.com/repos/strapi/strapi/issues/163/events","html_url":"https://github.com/strapi/strapi/issues/163","id":189330836,"number":163,"title":"Promise.deferred is obsoleted, and conflicts with babel","user":{"login":"fishmacs","id":1478581,"avatar_url":"https://avatars.githubusercontent.com/u/1478581?v=3","gravatar_id":"","url":"https://api.github.com/users/fishmacs","html_url":"https://github.com/fishmacs","followers_url":"https://api.github.com/users/fishmacs/followers","following_url":"https://api.github.com/users/fishmacs/following{/other_user}","gists_url":"https://api.github.com/users/fishmacs/gists{/gist_id}","starred_url":"https://api.github.com/users/fishmacs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fishmacs/subscriptions","organizations_url":"https://api.github.com/users/fishmacs/orgs","repos_url":"https://api.github.com/users/fishmacs/repos","events_url":"https://api.github.com/users/fishmacs/events{/privacy}","received_events_url":"https://api.github.com/users/fishmacs/received_events","type":"User","site_admin":false},"labels":[{"id":269635816,"url":"https://api.github.com/repos/strapi/strapi/labels/admin","name":"admin","color":"bfdadc","default":false},{"id":267208743,"url":"https://api.github.com/repos/strapi/strapi/labels/bug","name":"bug","color":"fc2929","default":true},{"id":422600310,"url":"https://api.github.com/repos/strapi/strapi/labels/v1.0","name":"v1.0","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2016-11-15T08:41:05Z","updated_at":"2016-11-28T09:57:29Z","closed_at":null,"body":"**5.3.0**:\r\n**2.15.11**:\r\n**1.5.4**:\r\n**OSX**:\r\n\r\napi/user/config/fixtures/route.js run into error:\r\n\r\n```\r\nerror:  TypeError: _promise2.default.defer is not a function\r\n    at Object.exports.create (/Users/zw/work/palmtao/IMSPortal/web/api/user/config/fixtures/route.js:18:28)\r\n    at /Users/zw/work/palmtao/IMSPortal/web/config/functions/bootstrap.js:16:29\r\n    at run (/Users/zw/work/palmtao/IMSPortal/web/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:87:22)\r\n    at /Users/zw/work/palmtao/IMSPortal/web/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:100:28\r\n    at flush (/Users/zw/work/palmtao/IMSPortal/web/node_modules/babel-runtime/node_modules/core-js/library/modules/_microtask.js:18:9)\r\n    at nextTickCallbackWith0Args (node.js:433:9)\r\n    at process._tickCallback (node.js:362:13)\r\nerror: Bootstrap encountered an error.\r\nerror:  TypeError: _promise2.default.defer is not a function\r\n    at Object.exports.create (/Users/zw/work/palmtao/IMSPortal/web/api/user/config/fixtures/route.js:18:28)\r\n    at /Users/zw/work/palmtao/IMSPortal/web/config/functions/bootstrap.js:16:29\r\n    at run (/Users/zw/work/palmtao/IMSPortal/web/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:87:22)\r\n    at /Users/zw/work/palmtao/IMSPortal/web/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:100:28\r\n    at flush (/Users/zw/work/palmtao/IMSPortal/web/node_modules/babel-runtime/node_modules/core-js/library/modules/_microtask.js:18:9)\r\n    at nextTickCallbackWith0Args (node.js:433:9)\r\n    at process._tickCallback (node.js:362:13)\r\n```\r\n\r\nI've changed it with new Promise(...), works ok\r\n\r\n```\r\nexports.create = function () {\r\n  // const deferred = Promise.defer();\r\n  const promises = [];\r\n  const newRoutes = [];\r\n  let routesFound;\r\n\r\n  return new Promise(function(resolve, reject) {\r\n    async.auto({\r\n      findRoutes: function (callback) {\r\n\r\n        // Find all routes.\r\n        strapi.orm\r\n          .collections\r\n          .route\r\n          .find()\r\n          .exec(function (err, routesFound) {\r\n            if (err) {\r\n              callback(err);\r\n            } else {\r\n              callback(null, routesFound);\r\n            }\r\n          });\r\n      },\r\n      deleteRoutes: ['findRoutes', function (callback, results) {\r\n\r\n        // Async dependencies.\r\n        routesFound = results.findRoutes;\r\n\r\n        // Delete destroyed routes.\r\n        _.forEach(routesFound, function (routeFound) {\r\n          if (!strapi.config.routes[routeFound.name]) {\r\n            promises.push(strapi.orm.collections.route.destroy({id: routeFound.id}));\r\n          }\r\n        });\r\n\r\n        callback(null);\r\n      }],\r\n      updateOrCreateRoutes: ['findRoutes', function (callback, results) {\r\n\r\n        // Async dependencies.\r\n        routesFound = results.findRoutes;\r\n        let verb;\r\n\r\n        // Find or create routes.\r\n        _.forEach(strapi.config.routes, function (route, key) {\r\n          verb = regex.detectRoute(key).verb;\r\n\r\n          // Check if the controller is a stringified function.\r\n          route.controller = _.startsWith(route.controller, 'function') ? 'Specific function' : route.controller;\r\n\r\n          if (_.find(routesFound, {name: key})) {\r\n            promises.push(strapi.orm.collections.route.update({\r\n              name: _.trim(key)\r\n            }, {\r\n              name: _.trim(key),\r\n              policies: route.policies,\r\n              controller: _.trim(route.controller),\r\n              action: _.trim(route.action),\r\n              verb: _.trim(verb)\r\n            }));\r\n          } else {\r\n            newRoutes.push(_.trim(key));\r\n            promises.push(strapi.orm.collections.route.create({\r\n              name: _.trim(key),\r\n              policies: route.policies,\r\n              controller: route.controller,\r\n              action: _.trim(route.action),\r\n              verb: _.trim(verb)\r\n            }));\r\n          }\r\n        });\r\n\r\n        callback(null);\r\n      }],\r\n      execRoutesModifications: ['deleteRoutes', 'updateOrCreateRoutes', function (callback) {\r\n\r\n        // Exec the promises.\r\n        Promise.all(promises)\r\n          .then(function (responses) {\r\n            callback(null, responses);\r\n          })\r\n          .catch(function (err) {\r\n            callback(err);\r\n          });\r\n      }],\r\n\r\n      findNewRoutes: ['execRoutesModifications', function (callback) {\r\n\r\n        // Find created routes.\r\n        strapi.orm\r\n          .collections\r\n          .route\r\n          .find({\r\n            'name': newRoutes\r\n          })\r\n          .populate('roles')\r\n          .exec(function (err, newRoutesFound) {\r\n            if (err) {\r\n              callback(err);\r\n            } else {\r\n              callback(null, newRoutesFound);\r\n            }\r\n          });\r\n      }],\r\n      updateCreatedRoutes: ['execRoutesModifications', 'findNewRoutes', 'findRoles', function (callback, results) {\r\n\r\n        // Async dependencies.\r\n        const newRoutesFound = results.findNewRoutes;\r\n        const roles = results.findRoles;\r\n\r\n        const userContributorRoutes = [\r\n          'GET /user/:id',\r\n          'PUT /user/:id',\r\n          'DELETE /user/:id'\r\n        ];\r\n\r\n        const userRegisteredRoutes = [\r\n          'PUT /user/:id',\r\n          'DELETE /user/:id'\r\n        ];\r\n\r\n        let verb;\r\n\r\n        const adminRole = _.find(roles, {\r\n          name: 'admin'\r\n        });\r\n\r\n        _.forEach(newRoutesFound, function (newRoute) {\r\n          if (!_.contains(newRoute.name, '/dashboard')) {\r\n\r\n            // Contributor permissions.\r\n            verb = regex.detectRoute(newRoute.name).verb;\r\n            newRoute.verb = _.trim(verb);\r\n            newRoute.isPublic = false;\r\n            newRoute.registeredAuthorized = false;\r\n            newRoute.contributorsAuthorized = false;\r\n\r\n            if (_.contains(newRoute.name, '/auth')) {\r\n              newRoute.isPublic = true;\r\n            } else if (_.contains(newRoute.name, '/user')) {\r\n              if (_.contains(userContributorRoutes, newRoute.name)) {\r\n                newRoute.contributorsAuthorized = true;\r\n              }\r\n              if (_.contains(userRegisteredRoutes, newRoute.name)) {\r\n                newRoute.registeredAuthorized = true;\r\n              }\r\n            } else {\r\n              if (verb === 'get') {\r\n                newRoute.isPublic = true;\r\n                newRoute.registeredAuthorized = true;\r\n              }\r\n\r\n              newRoute.contributorsAuthorized = true;\r\n            }\r\n\r\n            newRoute.roles.add(adminRole.id);\r\n\r\n            promises.push(new Promise(function (resolve, reject) {\r\n              newRoute.save(function (err) {\r\n                if (err) {\r\n                  reject(err);\r\n                }\r\n              });\r\n\r\n              resolve();\r\n            }));\r\n          }\r\n        });\r\n\r\n        Promise.all(promises)\r\n          .then(function (newRoutes) {\r\n            callback(null, newRoutes);\r\n          })\r\n          .catch(function (err) {\r\n            callback(err);\r\n          });\r\n\r\n      }],\r\n      findRoles: [function (callback) {\r\n\r\n        // Find roles.\r\n        strapi.orm\r\n          .collections\r\n          .role\r\n          .find()\r\n          .exec(function (err, roles) {\r\n            if (err) {\r\n              callback(err);\r\n            } else {\r\n              callback(null, roles);\r\n            }\r\n          });\r\n      }]\r\n    }, function cb(err, results) {\r\n      if (err) {\r\n        // deferred.reject(err);\r\n        reject(err);\r\n      } else {\r\n        // deferred.resolve(results);\r\n        resolve(results);\r\n      }\r\n    });\r\n\r\n    // return deferred.promise;\r\n  })\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/strapi/strapi/issues/comments/263229277","html_url":"https://github.com/strapi/strapi/issues/163#issuecomment-263229277","issue_url":"https://api.github.com/repos/strapi/strapi/issues/163","id":263229277,"user":{"login":"Aurelsicoko","id":4144726,"avatar_url":"https://avatars.githubusercontent.com/u/4144726?v=3","gravatar_id":"","url":"https://api.github.com/users/Aurelsicoko","html_url":"https://github.com/Aurelsicoko","followers_url":"https://api.github.com/users/Aurelsicoko/followers","following_url":"https://api.github.com/users/Aurelsicoko/following{/other_user}","gists_url":"https://api.github.com/users/Aurelsicoko/gists{/gist_id}","starred_url":"https://api.github.com/users/Aurelsicoko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aurelsicoko/subscriptions","organizations_url":"https://api.github.com/users/Aurelsicoko/orgs","repos_url":"https://api.github.com/users/Aurelsicoko/repos","events_url":"https://api.github.com/users/Aurelsicoko/events{/privacy}","received_events_url":"https://api.github.com/users/Aurelsicoko/received_events","type":"User","site_admin":false},"created_at":"2016-11-28T09:57:29Z","updated_at":"2016-11-28T09:57:29Z","body":"This is weird! I used the same npm and Node version as yours... And it works well on my side. I send you a PM on our Slack. I hope that we can find and share the solution on GitHub for helping others people."}}
{"actor":{"display_login":"Aurelsicoko"}}