Giter Site home page Giter Site logo

peimelo / blog_api Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 4.0 161 KB

Ruby on Rails 6 course as API showing authentication via devise_token_auth.

Home Page: https://course-blog-api.fly.dev

Ruby 95.32% HTML 0.28% Procfile 0.13% Dockerfile 4.28%
ruby-on-rails course api devise-token-auth video-course rspec devise

blog_api's Introduction

Blog API

Ruby on Rails 6 course as API showing authentication via devise_token_auth.

This repository is part of the Ruby on Rails 6 - Autenticação via API on YouTube.

Ruby version 3.0.3
Rails version 6.1.5
Database PostgreSQL

Configuration

git clone https://github.com/peimelo/blog_api.git
cd blog_api

# installation of dependencies
bundle install

# creation of database and tables
rails db:create
rails db:migrate
rails db:migrate RAILS_ENV=test

# run the project
rails s

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

Configuration for Production

# delete the config/credentials.yml.enc file
rm config/credentials.yml.enc

# run the command to create credentials and master key (replace 'code' if you don't use VS Code)
EDITOR="code --wait" bin/rails credentials:edit

Add the information below in the credentials to configure the email used by the Devise gem (replace with the values ​​you want):

# ... your content above

gmail:
  user_name: [email protected]
  password: your_password

exception_recipients: [email protected]

Save and close the config/credentials.yml.enc file.

If you want to use another email provider, change it in the file config/environments/production.rb.

To configure default_confirm_success_url, change it in the file config/initializers/devise_token_auth.rb.

To configure CORS origins, change it in the file config/initializers/cors.rb.

To configure Exception Notification, change it in the file config/initializers/exception_notification.rb.

Tests

Tests

To run the tests:

bundle exec rspec

Using Insomnia to test the API

If you want to import the 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:

password=your-password
access-token=your-access-token
client=your-client

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

{
  // ... your code above
  "envFilePath": "/path/to/file/your_repo/.env.development"
}

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

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