riverrun / phauxth_installer

No longer maintained - Installer for the Phauxth authentication library
13 stars 4 forks source link

Separate API and Web templates to make API + Web generation possible #8

Open BryanJBryce opened 5 years ago

BryanJBryce commented 5 years ago

If we create separate templates for API and Web we could offer to generate both API and Web files.

riverrun commented 5 years ago

I don't really understand this request :)

Could you give me a bit more information about what you are suggesting?

JohnKacz commented 5 years ago

Based on my own experience with the installer when I pass --api it removes the browser pipeline from the router and doesn't generate views (for obvious reasons).

So if I want to have both a web app and an json api then I need to run the installer twice (once with the --api flag and once with out it) and kind of merge the differences. Does that make any more sense?

riverrun commented 5 years ago

@JohnKacz could you show me what that setup looks like? Do you have an example app on github that I could look at?

BryanJBryce commented 5 years ago

@JohnKacz I didn't think about running the installer twice.

Are there any guidelines around what controllers should look like in a scenario where your Phoenix app has a web + api pieces?

BryanJBryce commented 5 years ago

@riverrun When you currently run the installer you get the choice between api or web. The templates are set up this way too, as an either or, but not both. I'm thinking a good approach to be able to generate both would be to have separate templates for api and for web.

I'm not sure, however, what the best practice is for controllers when you have both web and api parts. Does everything go into the same controller or do you separate web and api pieces into separate controllers? I think both pieces would use leverage the same contexts though.

I'll do some asking on the Elixir Slack and maybe in search the forum.

riverrun commented 5 years ago

@BryanJBryce that's the question I have - how best to set up the router and controllers. Once we have a better idea of what the recommended / best practices for that are, then we can work on implementing it.

JohnKacz commented 5 years ago

@riverrun No I don't have anything right now but I'll try to get something up sooner or later.

@BryanJBryce I don't have any off the top of my head but it shouldn't be too hard to figure out. Just a different pipeline which pipes through different controllers/views.