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
import { lessons } from "https://esm.town/v/petermillspaugh/lessons";
import { email as sendEmail } from "https://esm.town/v/std/email?v=11";
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
interface SendLessonParams {
lesson: number;
emailAddress: string;
}
export async function sendLesson({ lesson, emailAddress }: SendLessonParams) {
await sqlite.execute({
sql: `
UPDATE students
SET current_lesson = ?, has_completed_current_lesson = 0
WHERE email = ?;
`,
args: [lesson, emailAddress],
});
await sendEmail({
to: emailAddress,
from: {
name: "Make It Stick (in 10 days, via email)",
email: "petermillspaugh.sendLesson@valtown.email",
},
replyTo: "pete@petemillspaugh.com",
subject: `Lesson ${lesson + 1}: ${lessons[lesson].title}`,
html: lessons[lesson].fetchHtml(emailAddress, lesson),
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
January 20, 2024