{"action":"closed","issue":{"url":"https://api.github.com/repos/zeit/next.js/issues/239","repository_url":"https://api.github.com/repos/zeit/next.js","labels_url":"https://api.github.com/repos/zeit/next.js/issues/239/labels{/name}","comments_url":"https://api.github.com/repos/zeit/next.js/issues/239/comments","events_url":"https://api.github.com/repos/zeit/next.js/issues/239/events","html_url":"https://github.com/zeit/next.js/issues/239","id":188503348,"number":239,"title":"Use filesystem as poor man's REST API","user":{"login":"olifante","id":5111,"avatar_url":"https://avatars.githubusercontent.com/u/5111?v=3","gravatar_id":"","url":"https://api.github.com/users/olifante","html_url":"https://github.com/olifante","followers_url":"https://api.github.com/users/olifante/followers","following_url":"https://api.github.com/users/olifante/following{/other_user}","gists_url":"https://api.github.com/users/olifante/gists{/gist_id}","starred_url":"https://api.github.com/users/olifante/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olifante/subscriptions","organizations_url":"https://api.github.com/users/olifante/orgs","repos_url":"https://api.github.com/users/olifante/repos","events_url":"https://api.github.com/users/olifante/events{/privacy}","received_events_url":"https://api.github.com/users/olifante/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-10T13:04:50Z","updated_at":"2016-11-12T00:12:33Z","closed_at":"2016-11-12T00:12:33Z","body":"I see many people on Slack and in various GitHub Issues asking for some kind of backend solution. While I can sympathise with @rauchg's declaration that \"Data fetching is up to the developer\", having a basic solution that quickly helps beginners get started with next.js alone would be worth gold. With a simple extension of the wonderful idea of \"filesystem as API\", we could introduce an api/ folder containing .json files, which would then be automatically exposed as a JSON REST API.\r\n\r\nThus /api/posts.json would automatically create the GET collection endpoint http://example.com/api/posts/. Depending on whether the posts.json collection contains a top-level array or dictionary, the individual collection items would also be exposed as GET endpoints of the form http://example.com/api/posts/123/ or http://example.com/api/posts/abc/.\r\n\r\nDepending on the appetite for complexity on the implementer's side (i.e. @nkzawa and the rest of the zeit team), this basic REST API could be either read-only or also writeable, serving in the last case as a poor man's database. This probably would suffer from horrible limitations (concurrency problems?), but would nevertheless be usable for small low-volume sites and precious for beginners.\r\n\r\nThis would allow next.js to become a one-stop full-stack webdev solution for beginners, and eliminate the cognitive overload of having to choose and learn how to use one of micro, express, koa/koa2, hapi or feathersJS to create an API yourself (assuming we want to use node.js for the backend), or choosing and learning how to use some Backend-as-a-Service such as RethinkDB+Horizon, Firebase, Parse, Graph.cool or some other database exposing a JSON REST API or GraphQL API. Some of these approaches will of course be much better choices for production deployments, but once users get started with the built-in file-based JSON REST API, they would easily be able to migrate to a real 3rd party of self-built API.\r\n\r\nMaybe this could be coordinated with @rauchg's proposal for component API, detailed here: #149."}}
{"actor":{"display_login":"rauchg"}}