https://github.com/leogregianin/boox_api
Open Bookstore REST API with Elixir and Phoenix
https://github.com/leogregianin/boox_api
api-rest elixir elixir-phoenix
Last synced: 3 months ago
JSON representation
Open Bookstore REST API with Elixir and Phoenix
- Host: GitHub
- URL: https://github.com/leogregianin/boox_api
- Owner: leogregianin
- License: mit
- Created: 2022-01-26T00:49:16.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-26T01:35:35.000Z (over 3 years ago)
- Last Synced: 2024-12-27T21:43:26.593Z (5 months ago)
- Topics: api-rest, elixir, elixir-phoenix
- Language: Elixir
- Homepage: https://boox-api.gigalixirapp.com/api/books/
- Size: 57.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BooxApi
Open Bookstore REST API with Elixir and Phoenix
## Endpoints
* Base URL: `https://boox-api.gigalixirapp.com/api`
* GET `/books`
* GET `/books/:id`
* POST `/books`
* PUT `/books/:id`
* DELETE `/books/:id`
* PATCH `/books/:id`* Examples:
```
{
"book": {
"title": "Python Fluente",
"isbn": "978-85-7522-462-5",
"price": 50.51,
"description": "Programação clara, concisa e eficaz",
"authors": [
"Luciano Ramalho"
]
}
}
```## Step by step
* Install Erlang VM and Elixir
* Install Phoenix Framework `mix archive.install hex phx_new`
* Create new project `mix phx.new boox_api --no-html --binary-id`
* Build Postgres container `docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=boox_api -e POSTGRES_USER=boox_api --name postgrex postgres:alpine`
* Edit config/dev.exs e config/test.exs for database connection
* Run `mix ecto.create` for create `dev` database
* Change `export MIX_ENV=test`
* Run `mix ecto.create` for create `test` database
* Create books schema: `mix phx.gen.context Store Book books title:string isbn:text:unique description:text price:float authors:array:string`
* Running Migrations: `mix ecto.migrate`
* Generate JSON endpoint: `mix phx.gen.json Store Book books title:string isbn:text:unique description:text price:float authors:array:string --no-context --no-schema`
* Running tests: `mix test`
* Running server: `mix phx.server`## Local
To start your Phoenix server:
* Install dependencies with `mix deps.get`
* Create and migrate your database with `mix ecto.setup`
* Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server`Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
## Deploy
* [Gigalixir deployment](https://gigalixir.readthedocs.io/en/latest/getting-started-guide.html)
* API URL: `https://boox-api.gigalixirapp.com/api/books`## License
* BooxApi is licensed under the [MIT license](LICENSE).