{"action":"opened","issue":{"url":"https://api.github.com/repos/teamfa/sails-universal-react-starter/issues/6","repository_url":"https://api.github.com/repos/teamfa/sails-universal-react-starter","labels_url":"https://api.github.com/repos/teamfa/sails-universal-react-starter/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/teamfa/sails-universal-react-starter/issues/6/comments","events_url":"https://api.github.com/repos/teamfa/sails-universal-react-starter/issues/6/events","html_url":"https://github.com/teamfa/sails-universal-react-starter/issues/6","id":167189391,"number":6,"title":"How to use sails' blueprint routes for generated models","user":{"login":"stonebraker","id":1234785,"avatar_url":"https://avatars.githubusercontent.com/u/1234785?v=3","gravatar_id":"","url":"https://api.github.com/users/stonebraker","html_url":"https://github.com/stonebraker","followers_url":"https://api.github.com/users/stonebraker/followers","following_url":"https://api.github.com/users/stonebraker/following{/other_user}","gists_url":"https://api.github.com/users/stonebraker/gists{/gist_id}","starred_url":"https://api.github.com/users/stonebraker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stonebraker/subscriptions","organizations_url":"https://api.github.com/users/stonebraker/orgs","repos_url":"https://api.github.com/users/stonebraker/repos","events_url":"https://api.github.com/users/stonebraker/events{/privacy}","received_events_url":"https://api.github.com/users/stonebraker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-23T15:37:36Z","updated_at":"2016-07-23T15:37:36Z","closed_at":null,"body":"Following Sails conventions, I can generate a model with `sails generate model User`. This creates a ./api/models/User.js file off of the root project folder. Comparing this to the directory structure of sails-universal-react-starter, it seems that the model should have been placed in ./src/api/models. So I guess that's the first question. Where should Models be placed?\r\n\r\nThe second question is how can sails routes be configured to serve both the client interface (React app with server side rendering), as well as an API that exposes a restful interface to interact with domain models (entities such as a User or the Article model found in the starter code).\r\n\r\n`www.example.com/api/user` to expose restful methods for the User entity (blueprints or otherwise).\r\n\r\n`www.examples.com/everything`\r\n`www.examples.com/everything/else`\r\n`www.examples.com/including/deep/paths/for/deep/component/nesting`\r\n\r\nLooking at config/blueprints.js: ` restPrefix: '/api'`, it seems like this is how sails should be behaving, but accessing `/api/user` results in a 404 rather than the expected json response. This is true regardless of where the User.js model resides. `./api/models/User.js` or `./src/api/models/User.js`.\r\n\r\nTo keep things simple, I'm trying to merge the [react-router tutorial](https://github.com/reactjs/react-router-tutorial/tree/master/lessons) through lesson 9 into this project.\r\n\r\nThis is a very cool project. Would love to be able to utilize sails conventions and have server rendering of my react app. Let me know if I can provide any further information."}}
{"actor":{"display_login":"stonebraker"}}