chznbaum / dev-resources-api

API for development resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dev-Resources API

Maintainability Test Coverage Build Status

This API provides access to resources I've found helpful during my study of web and software development.

Getting Started

Prerequisites

Ruby 2.5.0

Download and manage via rbenv or RVM

Rails 5.1.5

gem install rails -v '~> 5.1'

PostgreSQL 10.3

Follow the instructions for downloading PostgreSQL based on your operating system, and be sure to create a database user with privileges.

Installing

Clone the repository:

git clone https://github.com/chznbaum/dev-resources-api.git
cd ./dev-resources-api

Install the gems:

bundle install

And set up the database:

rails db:create
rails db:migrate

Start the development server:

rails s

You can test this by making a GET request to localhost:3000 using Postman or an alternative.

API Reference

The API can be accessed from the URL https://floating-river-84963.herokuapp.com/ followed by the API endpoint.

For example: https://floating-river-84963.herokuapp.com/api/v1/resources/1

Authentication

Endpoints for creating or updating categories or resources require a JSON Web Token.

Authentication requests must be made to /api/v1/auth/login, and include an email and a password. Valid login credentials are limited to the API creator at this time.

An example response may look like the following:

{
    "access_token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE1MjA4MjEwNTV9.OwcvXUtkeyK-vyoAUQbSB16AqHRw9rmMfJUeCSXHEJs",
    "message": "Login successful."
}

Authentication is not required to access resource or category data.

Response Codes

All valid and properly formatted requests will return a HTTP status of 200. In the JSON response, there will also be a status field that will return "Successful" on such requests.

Endpoints

Log In

  • URL /api/v1/auth/login
  • Method: POST
  • Data Params: Required: email=[string] password=[string]
  • Success Response
    • Code: 200
    • Content: { "access_token": ..., "message": "Login successful." }
  • Error Response
    • Code: 401
    • Content: { "error": { "user_authentication": [ "Invalid credentials." ] } }

Index Resources

  • URL /api/v1/resources/
  • Method: GET
  • Data Params: Required: none
  • Success Response
    • Code: 200
    • Content: { "status": "Success", "message": "Loaded all resources.", "data": [ { "id": 1, "name": ..., "url": ..., "credit": ..., "description": ..., "category_id": ..., "created_at": ..., "updated_at": ... } ] }

Show Resource

  • URL /api/v1/resources/:id
  • Method: GET
  • Data Params: Required: none
  • Success Response
    • Code: 200
    • Content: { "status": "Success", "message": "Loaded resource: ....", "data": { "id": 1, "name": ..., "url": ..., "credit": ..., "description": ..., "category_id": ..., "created_at": ..., "updated_at": ... } }

Index Categories

  • URL /api/v1/categories/
  • Method: GET
  • Data Params: Required: none
  • Success Response
    • Code: 200
    • Content: { "status": "Success", "message": "Loaded all categories.", "data": [ { "id": 1, "name": ..., "description": ..., "created_at": ..., "updated_at": ... } ] }

Show Category

  • URL /api/v1/categories/:id
  • Method: GET
  • Data Params: Required: none
  • Success Response
    • Code: 200
    • Content: { "status": "Success", "message": "Loaded all categories.", "data": [ { "id": 1, "name": ..., "description": ..., "created_at": ..., "updated_at": ..., "resources": [ { "id": 1, "name": ..., "url": ..., "credit": ..., "description": ..., "category_id": ..., "created_at": ..., "updated_at": ... }, { "id": 1, "name": ..., "url": ..., "credit": ..., "description": ..., "category_id": ..., "created_at": ..., "updated_at": ... } ] } ] }

Built With

Contributing

Please read CONTRIBUTING.md for details on the code of conduct, and the process for submitting pull requests.

Versioning

v. 1.0 - Initial API release

Authors

  • Chazona Baum - Initial work

License

This project is licensed under the MIT License - see the LICENSE.md file for more details.

Acknowledgements

About

API for development resources

License:MIT License


Languages

Language:Ruby 99.3%Language:HTML 0.7%