A full JSON API using phoenix as backend, and a channel to view the new users in the database in real time.
To build this application I considered CORS which allows a web page to be requested from another domain outside the domain from which the resource originated, and for internal security the user's password will be kept in a hash; for the loading in real time I used the phoenix channel, which allowed me to add this features to the app.
- Install "Elixir"
- Install "Phoenix"
- Install "Postresql"
To use only in you local enviroment first clone this repository
- First clone the repository:
git clone https://github.com/GoberInfinity/ExamplePhoenix.git
- Change to the new directory:
cd ExamplePhoenix
- Create the database
mix ecto.create
(If you have an error here, check the database configuration at config/dev.exs) - Install the dependences
mix deps.get
- Finally run the local server
mix phoenix.server
Gets: You can get the json from the api typing:
~ curl -H "Content-Type: application/json" https://otherpoolapi.herokuapp.com/api/persons
~ curl -H "Content-Type: application/json" https://otherpoolapi.herokuapp.com/api/person_phones
~ curl -H "Content-Type: application/json" https://otherpoolapi.herokuapp.com/api/user_types
~ curl -H "Content-Type: application/json" https://otherpoolapi.herokuapp.com/api/userps
~ curl -H "Content-Type: application/json" https://otherpoolapi.herokuapp.com/api/sale_types
~ curl -H "Content-Type: application/json" https://otherpoolapi.herokuapp.com/api/saledetaills
Posts: You can post data from the api typing:
~ curl -H "Content-Type: application/json" -X POST -d '{"person": {"first_name":"Armando","middle_name":"Lara","last_name":"Hernandez","email":"richar@google.com","age":21, "birthday":"1996-05-05"}}' https://otherpoolapi.herokuapp.com/api/persons
~ curl -H "Content-Type: application/json" -X POST -d '{"person__phone": {"phone_number":320,"person_id":1}}' https://otherpoolapi.herokuapp.com/api/person_phones
~ curl -H "Content-Type: application/json" -X POST -d '{"user__type": {"name_type": "admin"}}' https://otherpoolapi.herokuapp.com/api/user_types
~ curl -H "Content-Type: application/json" -X POST -d '{"userp": {"password":"hola","person_id":1,"type_id":1}}' https://otherpoolapi.herokuapp.com/api/userps
~ curl -H "Content-Type: application/json" -X POST -d '{"sale__type": {"name_sale": "Event"}}' https://otherpoolapi.herokuapp.com/api/sale_types
~ curl -H "Content-Type: application/json" -X POST -d '{"saledetaill":{"order_date":"2017-05-05","due_date":"2017-05-06","subtotal":4000,"sale_type_id":1,"userp_id":2}}' https://otherpoolapi.herokuapp.com/api/saledetaills
Channel: To view the channel, go to : https://otherpoolapi.herokuapp.com/
, open the console and finally post a new person (only work for person model).
- Modeled the database in paper.
- Added the skeleton for deployment on Heroku.
- Created the models and the urls for the api.
- Added libraries for CORS, hashing and serializer.
- Failed to make a post using a serializer.
- Deleted serializer library.
- Final deployment.
- Reyes Fragoso Roberto - Portfolio