Giter Club home page Giter Club logo

elixir-phoenix-rest-api's Introduction

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:

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
  2. Set the env variable DATABASE_URL="ecto://user:password@db/rest_api_dev" (you may change the values)
  3. Create and migrate your database with mix ecto.create && mix ecto.migrate
  4. Start Phoenix endpoint with mix phoenix.server

Now you can visit 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
  2. Start Phoenix endpoint with docker-compose run --rm local

Now you can visit <container-ip>:<container-public-port> from your browser. Or in case your are using dockito-proxy api.local.dockito.org.

Example requests with CURL

List

curl http://api.local.dockito.org/posts

Create

curl -H "Content-Type: application/json" \
     -X POST \
     -d '{"post": {"title":"Title 001","content":"Content 001"} }' \
     http://api.local.dockito.org/posts

Update

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

curl -X DELETE \
     http://api.local.dockito.org/posts/1

Test

Testing Locally

mix test

Testing With Docker

docker-compose run --rm test

elixir-phoenix-rest-api's People

Contributors

maxcnunes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.