This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate a new context Todos with a database table Items. This table will have fields | |
# description:string | |
# priority:string | |
# is_done:boolean | |
mix phx.gen.live Todos Item items description:string priority:string is_done:boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# scaffold the todos UI app | |
npx create-react-app todos-ui | |
# move into the newly created directory | |
cd todos-ui | |
# install all dependencies | |
yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a new todo item | |
curl -H "Content-Type: application/json" -X POST -d '{"item":{"description":"learn elixir", "priority":1, "is_complete": false }}' http://localhost:4000/api/items | |
# list items | |
curl -H "Content-Type: application/json" -X GET http://localhost:4000/api/items |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in dev.ex, under | |
config :todos_api ... | |
debug_errors: false, | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate context & controller for a JSON resource | |
# this will create a migration that when run will create a table for items | |
# this table has a description, a priority level and a flag for whether the task is complete | |
mix phx.gen.json TodoItem Item items description:string priority:integer is_complete:boolean | |
# to run the migration we will use ecto again | |
mix ecto.migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run all tests | |
mix test | |
# fire up the server | |
# by default the server will be listening on http://localhost:4000 | |
mix phx.server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate a new app in a directory called todos-json-api | |
# namespaced under ToDosApi, & no html or webpack will scaffolded | |
mix phx.new todos-json-api --app todos_api --module ToDosApi --no-html --no-webpack | |
# go into newly created directory | |
cd todos-json-api | |
# create the database | |
mix ecto.create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To install postgres | |
brew update | |
brew install postgres | |
# To create new user (necessary step before you can create a database): | |
createuser -d postgres | |
# To start up postgres: | |
brew services start postgresql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
NewerOlder