CYPIAPT-LNDSE / welcome-to-camhs

Fun and accessible questionnaire for children when first visiting CAMHS.
https://welcome-in.herokuapp.com/
MIT License
5 stars 3 forks source link

Add send email functionality to finished page. #111

Closed RhodesPeter closed 7 years ago

RhodesPeter commented 7 years ago

Related #70 & #74

codecov-io commented 7 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@13f4490). Click here to learn what that means. The diff coverage is 63.63%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #111   +/-   ##
=========================================
  Coverage          ?   91.11%           
=========================================
  Files             ?        3           
  Lines             ?       45           
  Branches          ?        4           
=========================================
  Hits              ?       41           
  Misses            ?        4           
  Partials          ?        0
Impacted Files Coverage Δ
src/routes.js 100% <100%> (ø)
src/server.js 100% <100%> (ø)
src/send-email.js 50% <50%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 13f4490...146a543. Read the comment docs.

RhodesPeter commented 7 years ago

Hey @des-des, we have made most of the changes you suggested (I've pushed it up). Would it be possible to point us in the right direction in regards to making the sendMain function handle the errors correctly?

des-des commented 7 years ago

@RhodesPeter Send mail is an asynchronous function. It must either take a callback or return a promise. In the first case it will call the callback passing an error as the first argument. In the second case it will return a promise.reject object.

This means that sendmail will return control to the caller when the asynchronous action has resolved. With a hapi server, I try too keep as much business logic in the handler functions as possible (think of the handlers as the controllers if that helps). The handler will decide what to do in the case where sendmail fails.

For MVP, I would not worry too much about exactly what the handler / client would do in the error case, you can just throw back a 500 and log the error.

RhodesPeter commented 7 years ago

Ok @des-des - I have added a callback to the sendMail function. Is this what you had in mind?

des-des commented 7 years ago

@RhodesPeter yup perfect