forked from andrerpena/remoted
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playground.ts
47 lines (43 loc) · 1.15 KB
/
playground.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { config } from "dotenv";
import { buildDb } from "./server/db/build-db";
import { searchJobs } from "./server/graphql/services/job-service";
import * as path from "path";
import * as Email from "email-templates";
import { getCompanyByJobPublicId } from "./server/graphql/services/company-service";
config();
buildDb().then(async db => {
const jobs = await searchJobs(db, 10, 0);
for (const job of jobs) {
job.company = await getCompanyByJobPublicId(db, job.id);
console.log(job.company ? job.company.imageUrl : "nevermind");
}
const email = new Email({
message: {
from: "niftylettuce@gmail.com"
},
// uncomment below to send emails in development/test env:
// send: true
transport: {
jsonTransport: true
},
juice: true,
juiceResources: {
preserveImportant: true,
webResources: {
relativeTo: path.resolve("emails/newsletter"),
images: true
}
}
});
const emailResult = await email.send({
template: "newsletter",
message: {
to: "elon@spacex.com"
},
locals: {
name: "Elon",
jobs: jobs
}
});
console.log(emailResult);
});