Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restful API? #664

Open
eostrom opened this issue Jun 18, 2015 · 5 comments
Open

restful API? #664

eostrom opened this issue Jun 18, 2015 · 5 comments
Labels
Milestone

Comments

@eostrom
Copy link

eostrom commented Jun 18, 2015

I need to add a forum to an existing Rails app with an Angular front end. An option I'm considering is adopting Forem (which I've used before), taking advantage of its data model and possibly URL structure, and adding a JSON API. Does this sound like a good or bad idea to anyone?

And have you given any thought to an approach? It looks like the best options are either to integrate with the existing routes/controllers and add JSON views (maybe using RABL) or to build out a separate HTTP/URL structure (using something like Grape). I'm inclined to use RABL because that's what we're doing in the main engine of my application, but if there's a strong preference from the team, I'd rather do something that's likely to get integrated into Forem.

@radar
Copy link
Collaborator

radar commented Jun 20, 2015

For about a year now I've thought that Forem would be much better if it was just a JSON API without a frontend at all. A lot of people just customise the frontend or ditch it entirely. Most people don't use what we supply. I had a similar set of thoughts when I worked at Spree too.

I haven't had the time to invest in doing the work because I've been too busy with my full-time job and writing books.

I think it sounds like a step in the right direction. We should not use Rabl for this as I've had issues with it ; in my experience with building a Rabl-backed API for Spree. Grape is not that great either. I'm fine with it being straight jbuilder views in Rails.

I think it should comply with the JSON API specification. It should be versioned and access should be granted with user-based API keys (i.e. each user can have an API key generated to access Forem).

Please do it :)

@eostrom
Copy link
Author

eostrom commented Jul 12, 2015

What are your thoughts on view counts? In an API-based app, there isn't necessarily a one-to-one correspondence between a browser requesting data for a topic and a user viewing that topic. Should we bother having an explicit "views" API where a client can let the server know what the user's been looking at?

@radar
Copy link
Collaborator

radar commented Jul 13, 2015

I think if a topic has been retrieved directly (i.e a request like /forums/blah/topics/foo) then that should count as a view. Having a separate endpoint for this doesn't make much sense imo.

What's you're reasoning for having a separate endpoint?

@eostrom
Copy link
Author

eostrom commented Jul 14, 2015

I forget. I mean, I can imagine building an app in various ways that request a forum endpoint with included topic data, or that request topics and don't necessarily render them. But I'm not currently doing that, so maybe I was just overthinking it.

@vfonic
Copy link

vfonic commented Jul 20, 2015

Could it be an optional url parameter for such cases when you want to preload some forums/topics?
For example: /forums/blah/topics/foo?bump_view_counter=false

@krainboltgreene krainboltgreene added this to the v1 milestone Nov 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants