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

How to create a Phoenix app for API only #132

Open
SimonLab opened this issue Jan 28, 2020 · 7 comments
Open

How to create a Phoenix app for API only #132

SimonLab opened this issue Jan 28, 2020 · 7 comments

Comments

@SimonLab
Copy link
Member

I'm looking at creating the most basic Phoenix application which can be used for creating an API.
I know that Webpack is not required as an API will only returns json so managing assets is not necessary.
The html view and templates are also not required.

You can find the documentation on how to create a new project with mix help phx.new:
image

So we need to pass the --no-webpack and --no-html options when creating a new project.
ref:

@nelsonic
Copy link
Member

@SimonLab thanks for opening this issue! 🙌
Please capture as much detail as you can as we've been meaning to write a beginner-friendly Elixir API example app ever since dwyl/learn-elixir#102 ... ⏳

@SimonLab
Copy link
Member Author

I'm starting with Phoenix as it offers a lot of convenient features and because I've spend most of the time working with Phoenix itself than bare Elixir but I will try to research and implement an API server with only Elixir.

@nelsonic
Copy link
Member

@SimonLab I don't have much interest in building Elixir (Web) Apps without Phoenix.
Having a "framework" to organise code offers more benefits than the "performance overhead".
Don't waste time on building an API without Phoenix. 👍

@SimonLab
Copy link
Member Author

SimonLab commented Apr 29, 2020

I've now been rewriting (multiple times) the documentation on how to create an API with Phoenix.
I've kept the steps simple and I'll add more features on the next PRs:

  • Use Postgres to store quotes instead
  • Create the post endpoint to save quotes

@nelsonic
Copy link
Member

@SimonLab it's only worth adding Postgres for storing data that needs to be in Postgres.
the quotes.json file can easily be served without Postgres. 💭
If your plan is to create a Quotes App that allows people to add quotes fair enough. 🤔
But there's a chance that you're creating complexity for the user without too much benefit.

@SimonLab
Copy link
Member Author

My idea with Postgres is to be able to add and edit some quotes to show specifically how to create post and put endpoints/controller and how to send the request with a client, for exemple with curl.
I agree it might add some complexity but I think it can still be easy to follow has the code added won't be huge and the documentation will explain where to find the configuration for Postgres.

@nelsonic
Copy link
Member

@SimonLab sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants