Passed
Push — master ( e6aee2...1ab6c1 )
by Leandro
01:23
created

email.ts ➔ createEmail   A

Complexity

Conditions 1

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 1
1
import { createTransport } from "nodemailer";
2
import { isProduction } from "./global";
3
import Email from "email-templates";
4
import path from "path";
5
6
export function createEmail(): Email {
7
  return new Email({
8
    send: isProduction(),
9
    message: {
10
      from: process.env.EMAIL_FROM,
11
    },
12
    transport: createTransport({
13
      host: process.env.EMAIL_HOST,
14
      port: Number(process.env.EMAIL_PORT),
15
      auth: {
16
        user: process.env.EMAIL_USERNAME,
17
        pass: process.env.EMAIL_PASSWORD,
18
      },
19
    }),
20
    getPath: (type, template) => {
21
      return path.join(__dirname, "../emails", template, type);
22
    },
23
  });
24
}
25