https://github.com/kickinespresso/phx_gen_html_json
Phoenix HTML and JSON Generators Example
https://github.com/kickinespresso/phx_gen_html_json
elixir framework phoenix
Last synced: 6 days ago
JSON representation
Phoenix HTML and JSON Generators Example
- Host: GitHub
- URL: https://github.com/kickinespresso/phx_gen_html_json
- Owner: kickinespresso
- License: mit
- Created: 2018-03-09T18:33:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-09T20:31:59.000Z (about 7 years ago)
- Last Synced: 2025-02-17T05:15:17.012Z (3 months ago)
- Topics: elixir, framework, phoenix
- Language: Elixir
- Homepage: https://kickinespresso.com/posts/generating-html-and-json-scaffold-with-phoenix-1-3-1-3-2-generorators
- Size: 88.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PhxGenHtmlJson
[Blog Post](https://kickinespresso.com/posts/generating-html-and-json-scaffold-with-phoenix-1-3-1-3-2-generorators)
## Generators
mix phx.gen.html Blog Post posts title:string content:string
mix phx.gen.json Blog Post posts title:string content:string --web Api --no-context --no-schema### Other modifications
Add `as: :api` to `scope "/api", PhxGenHtmlJsonWeb.Api do` as shown below:
Generated Routes
scope "/api", PhxGenHtmlJsonWeb.Api do
pipe_through :api
...
resources "/posts", PostController
endModified for the correct route paths:
scope "/api", PhxGenHtmlJsonWeb.Api, as: :api do
pipe_through :api
...
resources "/posts", PostController
endInitally, for the project, we used the following command with `and`:
mix phx.gen.json Blog Post posts title:string content:string --web Api --no-context and --no-schema
This should have been removed and caused some issues with our `PhxGenHtmlJsonWeb.Api.PostControllerTest` test cases. The [8739c189b7c2a5d16e8fc9c047bdf65734beaa47](https://github.com/kickinespresso/phx_gen_html_json/commit/8739c189b7c2a5d16e8fc9c047bdf65734beaa47) change reflects what was needed to fix this issue.
## Starting
To start your Phoenix server:
* Install dependencies with `mix deps.get`
* Create and migrate your database with `mix ecto.create && mix ecto.migrate`
* Install Node.js dependencies with `cd assets && npm install`
* Start Phoenix endpoint with `mix phx.server`Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.