This is application, that will help during Lambda Days 2015 held in Cracow.
It uses Elixir, Postgres and the Phoenix Framework.
Skeleton is based on this blog post
Template updated to newest Elixir and Phoenix by rambocoder
To start your new Phoenix application you have to:
-
Copy and edit example dev config:
cp config/dev.example.exs config/dev.exs
-
Install dependencies with
mix deps.get
-
Run the migrations
mix ecto.migrate LambdaDays.Repo
-
Start Phoenix router with
mix phoenix.server
-
Kill it with Ctrl-C Ctrl-C
-
You can also start Phoenix with interactive Elixir shell
iex -S mix phoenix.server
-
Add first user to database:
admin = %LambdaDays.User{admin: true, email: "[email protected]", password: "admin", username: "admin"} LambdaDays.Repo.insert admin
-
Enjoy.
Now you can visit localhost:4000
from your browser.
- Learn basic elixir.
- Create admin and non-admin users.
- Provide authentication
- Provide API for MongooseIM auth
- Enable adding talks from Lambda Days
- Enable rating talks by users and external API
- Integrate with chat and streaming
To take all talks from the database just go to the page: talk_api/index
. Eg.
curl http://localhost:4000/talk_api/index
Sample response:
{
"talks":
[
{
"id":1,
"title":"sample_title",
"description":"sample_description"
"plus_votes":0,
"zero_votes":0,
"minus_votes":0,
},
{
"id":2,
"title":"sample_title_2",
"description":"sample_description_2"
"plus_votes":0,
"zero_votes":0,
"minus_votes":0,
}
]
}
Prepare file request.txt with content:
{
"id":1,
"plus_votes":1,
"zero_votes":2,
"minus_votes":4
}
and try to update talk using talk_api/update
REST api:
curl -X POST -d @request.txt http://localhost:4000/talk_api/update --header "Content-Type:application/json"
The result should be similar to the following:
{
"talk":
{
"id":1,
"title":"sample_title",
"description":"sample_description"
"plus_votes":1,
"zero_votes":2,
"minus_votes":4,
}
}