Skip to content

Firebase function for adding requested emails to the MailChimp email list

Notifications You must be signed in to change notification settings

CruzHacks/cruzhacks-mailing-microservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CruzHacks Mailing Microservice

cruzhacks-mailing-service

This Firebase Function is responsible for the CruzHacks mailing list. This service uses the MailChimp REST API.

Development

Dependnecies

  • Can be found inside package.json file. Installed using the following command:
    • yarn or yarn -i or yarn install within the /functions directory

Start

yarn serve

  • Begin an emulator suite at localhost:4000 with your function being served at localhost:5000. You can navigate the UI of the Emulator Suite to find the actual endpoint.
  • Note: Cors must properly be configured on the client side

Test

This project uses Jest. Run all tests via yarn test.

Environment Variables

Can be obtained by running firebase functions:config:get > .runtimeconfig.json within your /functions directory

Can be set by running firebase functions:config:set example.key="val"

Request Schema

curl --request GET \
  --url http://localhost:5001/cruzhacks-4a899/us-central1/subscribe \
  --header 'authentication: API_KEY' \
  --header 'content-type: application/json' \
  --data '{
    "email": "[email protected]"
  }'

Response Schemas

Successfully Added Email to Mailing List

{
  "error": false,
  "status": 201,
  "message": "[email protected] added to the mailing list"
}

User Already Exists

{
  "error": false,
  "status": 200,
  "message": "[email protected] is already subscribed"
}

Missing or Invalid API Key

{
  "error": true,
  "status": 401,
  "message": "Unable to authenticate request"
}

Missing Email in Request

{
  "error": true,
  "status": 400,
  "message": "Invalid or missing email in request body"
}

MailChimp Error

{
  "error": true,
  "status": 500,
  "message": "Mailchimp Error: ERROR MESSGE HERE."
}

Technologies

  • Firebase Functions
  • NodeJS
  • Jest
  • Github Actions
  • Prettier
  • Eslint

About

Firebase function for adding requested emails to the MailChimp email list

Topics

Resources

Stars

Watchers

Forks