Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vbrazo/blog_api
A fully-fledged backend Blog API with Phoenix
https://github.com/vbrazo/blog_api
Last synced: about 1 month ago
JSON representation
A fully-fledged backend Blog API with Phoenix
- Host: GitHub
- URL: https://github.com/vbrazo/blog_api
- Owner: vbrazo
- License: mit
- Created: 2021-04-25T21:52:57.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-22T19:10:09.000Z (about 3 years ago)
- Last Synced: 2024-05-21T12:10:44.100Z (6 months ago)
- Language: Elixir
- Homepage:
- Size: 320 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Blog API in Phoenix
This codebase was created to demonstrate a fully fledged backend API with **Elixir and Phoenix** including CRUD operations, authentication, routing, pagination, and more.
We've gone to great lengths to adhere to the **[credo](https://github.com/rrrene/credo)** community style guides & best practices.
- [Blog API in Phoenix](#blog-api-in-phoenix)
- [Installation](#installation)
- [Database schema](#database-schema)
- [API Endpoints](#api-endpoints)
- [Tests](#tests)
- [Documentation](#documentation)
- [Style guide](#style-guide)
- [Licensing](#licensing)## Installation
To run this project, you will need to install the following dependencies on your system:
* [Elixir](https://elixir-lang.org/install.html)
* [Phoenix](https://hexdocs.pm/phoenix/installation.html)
* [PostgreSQL](https://www.postgresql.org/download/macosx/)To get started, run the following commands in your project folder:
| Command | Description |
|-----------------------------------------------|----------------------------------------------|
| `cp config/dev.exs.example config/dev.exs` | creates the project's configuration file |
| `mix deps.get` | installs the dependencies |
| `mix ecto.create` | creates the database |
| `mix ecto.migrate` | run the database migrations |
| `mix phx.server` | run the application |This is a backend project, you won't be able to go to `localhost:4000` and see a Frontend application. You can test the API endpoint using Postman or Insomnia.
## Database schema
## API Endpoints
| Route | Controller | Action | HTTP method |
|-------------------------------|--------------------------|--------------|--------------|
| `/articles/feed` | ArticleController | feed | GET |
| `/articles` | ArticleController | index | GET |
| `/articles/:id` | ArticleController | show | GET |
| `/articles` | ArticleController | create | POST |
| `/articles/:id` | ArticleController | put/patch | PUT/PATCH |
| `/articles/:id` | ArticleController | delete | DELETE |
| `/articles/:slug/favorite` | ArticleController | favorite | POST |
| `/articles/:slug/favorite` | ArticleController | unfavorite | DELETE |
| `/comments` | CommentController | index | GET |
| `/comments/:id` | CommentController | show | GET |
| `/comments` | CommentController | create | POST |
| `/comments/:id` | CommentController | put/patch | PUT/PATCH |
| `/comments/:id` | CommentController | delete | DELETE |
| `/tags` | TagController | index | GET |
| `/user` | UserController | current_user | GET |
| `/user` | UserController | update | PUT |
| `/users` | UserController | create | POST |
| `/users/login` | SessionController | create | POST |
| `/profiles/:username` | ProfileController | show | GET |
| `/profiles/:username/follow` | ProfileController | follow | POST |
| `/profiles/:username/follow` | ProfileController | unfollow | DELETE |## Tests
To run the tests for this project, simply run in your terminal:
```shell
mix test
```## Documentation
To generate the documentation, your can run in your terminal:
```shell
mix docs
```This will generate a `doc/` directory with a documentation in HTML. To view the documentation, open the `index.html` file in the generated directory.
## Style guide
This project uses [mix format](https://hexdocs.pm/mix/master/Mix.Tasks.Format.html). You can find the configuration file for the formatter in the `.formatter.exs` file.
## Licensing
MIT © Vitor Oliveira