Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1555 Build endpoint for sending project updates #1616

Merged

Conversation

dhochbaum-dcp
Copy link
Collaborator

@dhochbaum-dcp dhochbaum-dcp commented Dec 6, 2024

Summary

Build new endpoint to trigger project update emails for given project

  • New POST endpoint to /projects/<projectid>/send-update
  • Calls Sendgrid APIs to create single sends for project to correct CD and citywide lists with correct metadata.
  • Endpoint requires Authorization header implementing Basic authorization method. Credentials should be username:password base64 encoded. Username can be ae-admin, password should be randomly generated UUID to be stored as environment variable. If given authorization header contains incorrect credentials, return 401 Unauthorized response.
  • If single sends are created and scheduled succesfully, return 200
  • If project with given id not found, return 404

Tasks/Bug Numbers

Technical Explanation

I ended up not needing to add any dependencies for this endpoint. 🎉

We did not need anything to manage users, since we do not have multiple users. Basic authorization only requires that we ensure that the username:password base64 encoded sent with the request is correct. I added a module/service to handle this portion. Because this is a different authentication than is used elsewhere on the server, and is limited to a single endpoint, I was able to put the authorization in the controller, rather than needing to add it as middleware.

We had discussed potentially using Handlebars, but there did not appear to be any packages that provide out-of-the-box support for our use case. There is support for either using Handlebars as your primary means of templating, and support for using Handlebars to precompile your site using a CLI; but they are not suited for importing a Handlebars template, populating it on the fly, and returning an HTML string. Because of this, it would be overkill for us to come up with a complex implementation when the MVP requires only a single email template for this purpose, when instead we could simply use template literals.

Any other info you think would help a reviewer understand this PR?

@dhochbaum-dcp dhochbaum-dcp requested a review from a team as a code owner December 6, 2024 16:52
Copy link

netlify bot commented Dec 6, 2024

Deploy Preview for labs-zap ready!

Name Link
🔨 Latest commit 53e99ae
🔍 Latest deploy log https://app.netlify.com/sites/labs-zap/deploys/6760728d78fb6c0008190d4d
😎 Deploy Preview https://deploy-preview-1616--labs-zap.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@dhochbaum-dcp dhochbaum-dcp force-pushed the 1555/build-endpoint-for-sending-project-updates branch from a535f66 to e4d6bce Compare December 9, 2024 14:41
server/src/listserv/auth.module.ts Outdated Show resolved Hide resolved
server/src/send-update/send-update.controller.ts Outdated Show resolved Hide resolved
server/src/send-update/send-update.controller.ts Outdated Show resolved Hide resolved
@dhochbaum-dcp dhochbaum-dcp force-pushed the 1555/build-endpoint-for-sending-project-updates branch 3 times, most recently from f5f1bf6 to f877506 Compare December 11, 2024 18:48
@dhochbaum-dcp dhochbaum-dcp force-pushed the 1555/build-endpoint-for-sending-project-updates branch from f877506 to 18b2486 Compare December 13, 2024 15:28
@dhochbaum-dcp dhochbaum-dcp merged commit 4b49e71 into develop Dec 16, 2024
5 checks passed
@dhochbaum-dcp dhochbaum-dcp deleted the 1555/build-endpoint-for-sending-project-updates branch December 16, 2024 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build endpoint for sending project updates
2 participants