-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (28 loc) · 1.06 KB
/
index.js
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
// Import packages
const { initializeApp } = require("firebase/app")
const express = require('express');
const path = require('path');
const fs = require("fs");
const {sendEmailWithTwilio, sendWarningEmailWithTwilio} = require("./sendGrid")
require('dotenv').config({ path: 'sendgrid.env' })
// Initiate the express server
const app = express();
const port = 8080;
// Trigger email service in Twilio
app.post("/email", async(req,res) => {
// declare your username and email <--- please change to your name and uncomment this line
const username = process.env.USERNAME
const email = process.env.EMAIL
sendEmailWithTwilio(username, email);
res.json({success:true});
})
app.post("/warning", async(req,res) => {
// declare your username and email <--- please change to your name and uncomment this line
const username = process.env.USERNAME
sendWarningEmailWithTwilio(username);
res.json({success:true});
})
app.use(express.static(path.join(__dirname, 'public')));
app.listen(port, () => {
console.log(`Listening at PORT ${port}`);
})