Giter Site home page Giter Site logo

peimelo / curso_tour_of_heroes_api Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 6.0 368 KB

Ruby on Rails 6 course as an API creating a Heroes CRUD.

Home Page: https://curso-tour-of-heroes-api.fly.dev

Ruby 79.91% HTML 13.04% Dockerfile 6.87% Procfile 0.18%
ruby-on-rails rails-api tour-of-heroes curso cursoemvideo rspec

curso_tour_of_heroes_api's Introduction

Tour Of Heroes API

Ruby on Rails 6 course as an API creating a Heroes CRUD.

This repository is part of the Curso de Ruby on Rails 6 como API on YouTube.

Ruby version 3.0.3
Rails version 6.1.x
Database SQLite3 (dev) / PostgreSQL (prod)

Initial settings to run the project

# clone the project
git clone https://github.com/peimelo/curso_tour_of_heroes_api.git

# enter the cloned directory
cd curso_tour_of_heroes_api

# install Ruby on Rails dependencies
bundle install --without production

# create the development and test databases
rails db:create

# create the tables
rails db:migrate

# run the project
rails s

The backend is available at http://localhost:3000.

Tests

Tests

To run the tests:

rspec

Using the HEROES API

Include a Header Authorization

For all requests, use an Authorization header, of size >= 10 characters, so that you can only manipulate your data, for example:

curl --request GET \
  --url 'https://curso-tour-of-heroes-api.herokuapp.com/api/heroes' \
  --header 'Authorization: anyTokenCanBeUsed'

API Endpoint

The following endpoints are available:

Endpoints Usage Params
GET /api/heroes Get all of the heroes.
GET /api/heroes?name=term Get all heroes with name like a term. term: [String]
GET /api/heroes/:id Get the details of a single hero.
POST /api/heroes Add a new hero. name: [String]
PUT /api/heroes/:id Edit the details of an existing hero. name: [String]
DELETE /api/heroes/:id Remove the hero.

Using Insomnia to test the API

If you want to import the above requests into Insomnia, use the file Insomnia.json at the root of this project.

It will be necessary to install the plugin insomnia-plugin-dotenv.

Create an environment variable file at the root of the project to add sensitive data:

touch .env.development

Add the contents below to the file above:

token=anyTokenCanBeUsed

In Insomnia, go to Manage Environments and set the envFilePath value to the file path .env.development:

{
  "baseUrl": "http://localhost:3000/api",
  "envFilePath": "/path/to/file/your_repo/.env.development"
}

Any .env.* file is being ignored by this project's GIT.

curso_tour_of_heroes_api's People

Contributors

peimelo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.