Using:
- Elixir v1.10 released
- Phoenix Framework v1.4.14
- Ecto v3.1
To start this project:
- git clone this repository
- Configure database params in ./config/dev.exs
# Configure your database config :project_name, ProjectName.Repo, username: "username", password: "password", database: "database_name", hostname: "host", show_sensitive_data_on_connection_error: true, pool_size: 10
- Install dependencies with
mix deps.get
- Create and migrate your database with
mix ecto.setup
- Execute this command seeds for insert data demo in database
mix run priv\repo\seeds\user_seeds.exs
andmix run priv\repo\seeds\tweet_seeds.exs
- Install Node.js dependencies with
cd assets && npm install
- Start Phoenix endpoint with
mix phx.server
Now you can visit localhost:4000
from your browser.
- Using Postman or Insomnia
- Methods and Routes
Method | Route |
---|---|
GET | http://localhost:4000/api/users |
GET | http://localhost:4000/api/users/:id |
POST | http://localhost:4000/api/users |
GET | http://localhost:4000/api/tweets |
GET | http://localhost:4000/api/tweets/:id |
POST | http://localhost:4000/api/tweets |
GET | http://localhost:4000/api/tweets/user/:user_id |
- Models
{"user": { "name": "name", "nickname": "nickname", "email": "[email protected]", "password": "1234" } } {"tweet": { "user_id": 20, "text": "First tweet test", "likes": 12, "created_at": "2020-02-22 19:54:41" } }
Ready to run in production? Please check our deployment guides.
- Official website: https://www.phoenixframework.org/
- Guides: https://hexdocs.pm/phoenix/overview.html
- Docs: https://hexdocs.pm/phoenix
- Forum: https://elixirforum.com/c/phoenix-forum
- Source: https://github.com/phoenixframework/phoenix