Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxcnunes/elixir-phoenix-rest-api
A simple example of a rest API with elixir and phoenix
https://github.com/maxcnunes/elixir-phoenix-rest-api
Last synced: 3 months ago
JSON representation
A simple example of a rest API with elixir and phoenix
- Host: GitHub
- URL: https://github.com/maxcnunes/elixir-phoenix-rest-api
- Owner: maxcnunes
- Created: 2015-12-16T00:10:28.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-11-04T07:47:58.000Z (about 3 years ago)
- Last Synced: 2024-10-15T15:47:13.293Z (3 months ago)
- Language: Elixir
- Homepage:
- Size: 62.5 KB
- Stars: 75
- Watchers: 5
- Forks: 20
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Elixir Phoenix Rest API
This project is all generated by phoenix framework.
Actually I just spent time removing the static files and configuring the application to run with docker.
Which is a good point to the framework because at least to the bootstrap makes everything faster and easier.Cloning this project:
```bash
git clone [email protected]:maxcnunes/elixir-phoenix-rest-api.git rest_api
```## Development
### Running Locally
To start your Phoenix app:
1. Install dependencies with `mix deps.get`
1. Set the env variable `DATABASE_URL="ecto://user:password@db/rest_api_dev"` (you may change the values)
1. Create and migrate your database with `mix ecto.create && mix ecto.migrate`
1. Start Phoenix endpoint with `mix phoenix.server`Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
### Running With Docker
1. Create and migrate your database with `docker-compose run --rm local sh -c "mix ecto.create && mix ecto.migrate`
1. Start Phoenix endpoint with `docker-compose run --rm local`Now you can visit `:` from your browser.
Or in case your are using [dockito-proxy](https://github.com/dockito/proxy) [api.local.dockito.org](api.local.dockito.org).### Example requests with CURL
**List**
```bash
curl http://api.local.dockito.org/posts
```**Create**
```bash
curl -H "Content-Type: application/json" \
-X POST \
-d '{"post": {"title":"Title 001","content":"Content 001"} }' \
http://api.local.dockito.org/posts
```**Update**
```bash
curl -H "Content-Type: application/json" \
-X PUT \
-d '{"post": {"title":"Title 001 Updated","content":"Content 001 Updated"} }' \
http://api.local.dockito.org/posts/1
```**Delete**
```bash
curl -X DELETE \
http://api.local.dockito.org/posts/1
```## Test
### Testing Locally
```shell
mix test
```### Testing With Docker
```shell
docker-compose run --rm test
```