Git Product home page Git Product logo

address_book_api's Introduction

Contacts Lab with Email and Sidekiq

The goal of this lab is to create a simple rails app that can send emails. In order to do this, you're going to create a backend api (a separate rails app) that has the ability to send emails.

Contacts App

The front end app is already given to you in this repo under the contacts_front_end directory. Most of the code is done. You just need to implement 3 methods in the controller to get an email from the user. Your contacts front end should send api request to the app in the email_sender directory.

Email Sender App

In the email sender app, you should only have 1 api to worry about. The request you will make will be a post request to /email. The /email api should be called using /email.json from your front end since that is the format you want your server to respond with. The email api will need 3 pieces of information:

  • email address for the To field of the email
  • subject of the email
  • body of the email

Sidekiq

We want our api to respond to our rails front end quickly. Therefore the email sending should happen in a sidekiq worker. In your email sender backend, use sidekiq when you get to sending an email. At first, start out having your code in the controller, then once you get it working, move it to a worker.

Emailing

Use action mailer to send your email. For more information on how to do this, use these notes

Hints

  • To get both servers running at the same time, you can run one of the servers on a different port. The command for that is:
rails s -p 3001
  • Don't worry about sidekiq, emailing or anything else at first. Just get one server talking to another. Add the code in your front end that makes an api request to your back end. Veryify that your back end gets data.
  • Make sure to change your back end to protect_from_forgery with: :null_session in app/controllers/application_controller.rb.
  • When you get to implementing the worker in the email sender backend, just give the worker the email address, subject and body as parameters to preform. It does not make sense for you to save the data in the database.

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.