0.0.1 • Published 4 years ago
microservice-email v0.0.1
Email Microservice
Description
This microservice can be used by multiple projects and supports multiple email providers.
Environment Variables
PORT="3000"
API_LOGGER="true"
GOOGLE_APPLICATION_PROJECT="google project"
GOOGLE_APPLICATION_CREDENTIALS="/etc/config/pubsub.json"
PUBSUB_TOPIC="pubsub topic name"
PUBSUB_SUBSCRIPTION="pubsub subscription name"
EMAIL_CONFIG="config in JSON string"
Sample Email Config
All projects should be added in this config json string with their corresponding email providers and api keys.
{
"mthp": {
"emailProviders": [
{"provider": "sendgrid", "apiKey": "secretKey"},
{"provider": "mailchimp", "apiKey": "secretKey"}
],
"emailSettings": {
"fromEmail": "no-reply-mytotalhealth@mclinica.com",
"fromAlias": "MyTotalHealth no-reply"
}
},
"stayon": {
"emailProviders": [
{"provider": "sendgrid", "apiKey": "secretKey"}
],
"emailSettings": {
"fromEmail": "no-reply-stayon@mclinica.com",
"fromAlias": "StayOn no-reply"
}
},
"mycare": {
"emailProviders": [
{"provider": "mailchimp", "apiKey": "secretKey"}
],
"emailSettings": {
"fromEmail": "no-reply-mycare@mclinica.com",
"fromAlias": "MYCare no-reply"
}
},
"connect_platform": {
"emailProviders": [
{"provider": "sendgrid", "apiKey": "secretKey"}
],
"emailSettings": {
"fromEmail": "no-reply-connectplatform@mclinica.com",
"fromAlias": "ConnectPlatform no-reply"
}
}
}
PubSub Payload Examples
{
"project": "connect_platform", // project code
"provider": "sendgrid", // email provider name
"emailPayload": {
"toEmail": ["example_2@email.com"], // array of email receiver
"cc": ["example_3@email.com"], // array of email carbon copy
"bcc": ["example_4@email.com"], // array of email blind carbon copy
"subject": "connect platfrom development", // subject of email
"content": "Hi, this email is just for development purposes", // content of email
"attachments": [ // array of attachments
{
"fileName": "sample_file_name", // desired filename
"fileUrl": "https://cloud.storage/etc/sample_file.pdf", //link from cloud storage
}
]
}
}
Supported Mime Types/Internet Media Types and File Extension
[
{ type: "application/pdf", extension: ".pdf" },
{ type: "text/csv", extension: ".csv"},
{
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
extension: ".docx"
},
{
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
extension: ".xlsx"
},
{ type: "image/png", extension: ".png" },
{ type: "image/jpeg", extension: ".jpg" },
{ type: "image/jpeg", extension: ".jpeg" },
{ type: "image/svg+xml", extension: ".svg"}
]
Pre-requisites
- Google PubSub Service Account
- Google Pubsub Topic
- Google Pubsub Subscription
- SendGrid API Key and Secret Key
How to run
npm install
npm start
0.0.1
4 years ago