Skip to content

vitorguima/wall_app_api

Repository files navigation

Wall app API

The Wall API serves the backend for the Wall client. This API enables users to create, delete, update and read posts. The application was built with Ruby, Rails and SQLite.

API deployment at Heroku:

How to run this project on your local environment

Clone this repository to your local environment:

git clone [email protected]:vitorguima/wall_app_api.git

Before running the project, certify you have the necessary dependencies installed in your computer:

After installing all the required dependencies:

  • Create a .env file inside the project's root folder with the same variables that have been defined in the .env.example file.
  • Access the project's root folder, open a new terminal and run the following command: bundle install
  • After installing the project's dependencies, run: bin/rails s

Tests

The tests are of the integration type. Those were written to validate the behavior of the application for the different endpoints of this API. As the tests validates the request flow and it's outputs, all of those are based on the expectations for each endpoint and the tested http method.

To run the tests:

Open a new bash inside the project's root folder and run the command below:

rspec spec --format documentation

How does Wall API works

Registering

The first step to use the Wall API is to create a user by sending a request to the following endpoint:

Authenticating

After creating an user, you must authenticate yourself before start making new requests to the Wall API. As the API works with JWT credentials, every request that changes data in our database must cointain a valid token at it's header.

API complete documentation

After registering and authenticating an user will be able to CREATE, DELETE and UPDATE new posts. All available endpoints and it's required parameters are documented in the link below:

External libraries

  • bcrypt: to encode passwords.
  • JWT: to handle access tokens.
  • rspec: to implement tests.
  • dotenv: to import environment variables from .env.
  • Factory bot: support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects).

Concerns

  • Endpoints that retrieves a generic list with no pagination rule. If this list increase too much, the API will always be retrieving all the data from the database and consuming a lot of resource.
  • It's possible to register a new user with a fake email (there's no validation service for that)
  • The mailer service is using my personal email (no service like sendgrid was used on this pilot)