aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Check.svelte
blob: 4c9f504b09619f581174cb478f6c2796b4194e65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
<svg
	class="flex-shrink-0 w-5 h-5 text-gray-500 mr-1"
	fill="currentColor"
	viewBox="0 0 20 20"
	xmlns="http://www.w3.org/2000/svg"
	><path
		fill-rule="evenodd"
		d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
		clip-rule="evenodd"
	/></svg
>
div>
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

                             
                                

                                           



                                             
 

                                              
 
                                                              
 






                                                    
         
 








                                              
   
import app from "$app";
import config from "$config";
import persist from "./persist";
const emails = persist("data/emails.json");

app.post("/email", async (req, res) => {
  try {
    let file = persist("data/emails.json");
    file.emails = [...file.emails, req.body];

    try {
      var postmark = await import("postmark");

      var client = new postmark.ServerClient(config.postmark);

      await client.sendEmail({
        From: "[email protected]",
        To: "[email protected]",
        Subject: req.body.subject || "Email Signup",
        HtmlBody: JSON.stringify(req.body),
        TextBody: JSON.stringify(req.body),
        MessageStream: "outbound"
      });

      res.send({ ok: true });
    } catch (e) {
      console.log("problem sending email", e);
      res.code(500).send(e.message);
    }
  } catch (e) {
    console.log(e);
    res.code(500).send(e.message);
  }
});