GithubHelp home page GithubHelp logo

ecommerce-api's Introduction

Ecommerce API Ruby 3.1.2 Rails 7 - This api is for didactic purposes

Install Dependencies

  • Distros Debian based
sudo apt install libssl-dev
  • Distros RedHat based
yum install openssl-devel

start project with flag -T to skip minitest

rails new ecommerce-api --api -d mysql -T

install and config mailcatcher then test it - config/environments/development.rb

gem install mailcatcher

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 }

Customize your reset password

  • pre visualize your email page
mkdir -p test/mailers/previews/devise

cat << EOF >> test/mailers/previews/devise/mailer_preview.rb
  class Devise::MailerPreview < ActionMailer::Preview
    def reset_password_instructions
      Devise::Mailer.reset_password_instructions(User.first, {})
    end
  end
EOF

http://localhost:3000/rails/mailers/devise/mailer/reset_password_instructions

[add in test/mailers/previews/devise]

class Devise::MailerPreview < ActionMailer::Preview
  def reset_password_instructions
    Devise::Mailer.reset_password_instructions(User.first, {})
  end
end
ActionMailer::Base.mail(to: '[email protected]', from: '[email protected]', subject: 'Apenas Testando', body: 'xD').deliver_now!

install and configure devise_token_auth

rails g devise:install
rails g devise_token_auth:install User auth/v1/user
rails db:migrate

rails g devise:views -v mailer

generate controllers

rails g controller admin/v1/api
rails g controller storefront/v1/api

Config locales - [add in config/application.rb]

active_record.pt-BR.yml

devise.pt-BR.yml

# I18n config
config.i18n.load_path += Dir[Rails.root.join('config/locales/**/*.{rb,yml}')]
config.i18n.default_locale = :'pt-BR'
mkdir -p config/locales/pt-BR
touch config/locales/pt-BR/{active_record,devise}.yml

configure tests unit with Rspec

  • add to gemfile
group :development, :test do
  gem 'factory_bot_rails'
  gem 'faker'
  gem 'rspec-rails', '~> 4.0.1'
  gem 'shoulda-matchers', '~> 4.0'
end
bundle install && rails g rspec:install
  • configure factory_bot and shoulda_matchers
mkdir -p spec/support

cat << EOF >> spec/support/factory_bot.rb
  RSpec.configure do |config|
    config.include FactoryBot::Syntax::Methods
  end
EOF

cat << EOF >> spec/support/shoulda_matchers.rb
  Shoulda::Matchers.configure do |config|
    config.integrate do |with|
      with.test_framework :rspec
      with.library :rails
    end
  end
EOF

[ add in spec/rails_helper.rb ]

require 'rspec/rails'

Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }

install active storage

rails active_storage:install
rails db:migrate
  • will generate a configuration file - config/storage.yml

  • setup your active storage service to local config/environments/development.rb

config.active_storage.service = :local

ecommerce-api's People

Contributors

jesherdevsk8 avatar

Stargazers

 avatar

Watchers

 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.