0.5.1 • Published 4 years ago

@tutorbook/emails v0.5.1

Weekly downloads
1
License
SEE LICENSE IN LI...
Repository
github
Last release
4 years ago

Emails

This repository contains all of our Handlebars.js email templates. We use Twilio SendGrid to send our emails and Handlebars to send customized HTML email templates.

Usage

Just import the email template you want to use, initialize it, and send it via SendGrid's Node.js SDK like so:

import { ParentApptEmail, Email } from '@tutorbook/emails';
import mail from '@sendgrid/mail';

mail.setApiKey(process.env.SENDGRID_API_KEY as string);

const email: Email = new ParentApptEmail(parent, recipient, appt, recipients);
await mail.send(email);

Structure

Since we have a lot of emails and thus a lot of templates, this package is actually rather large. It is organized like:

.
├── declarations.d.ts
├── email.ts
├── handlebars.ts
├── appt
│   ├── index.ts
│   └── template.hbs
├── parent-appt
│   ├── index.ts
│   └── template.hbs
└── verification
    ├── index.ts
    └── template.hbs

3 directories, 9 files

There are three top-level files that are shared by all our email templates:

  1. The declarations.d.ts file defines the *.hbs module type so that Typescript doesn't error when we import our Handlebars templates.
  2. The email.ts file defines an Email interface that extends SendGrid's required MailData interface (it adds required recipient and html properties). This interface is implemented by each of our email templates.
  3. The handlebars.ts file defines some useful (and shared) Handlebars custom helpers.

Each email template then has it's own directory and includes:

  1. The index.ts email definition file that contains the class that implements the Email interface. This class can be initialized and sent via SendGrid.
  2. The template.hbs Handlebars file contains the HTML email template.

Each email template directory can have additional files but is required to have the two above listed files.

0.5.1

4 years ago

0.3.9

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago