-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (31 loc) · 861 Bytes
/
Copy pathindex.js
File metadata and controls
37 lines (31 loc) · 861 Bytes
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
import express from 'express';
import dotenv from 'dotenv';
import getCompanyInfo from './controller/getCompanyInfo.js';
import mailSender from './sendMail.js';
dotenv.config();
const app = express();
const PORT = process.env.PORT || 4000;
// Home route
app.get('/', (req, res) => {
res.send("Server is running 🚀");
});
// API to send bulk emails from Google Sheet
app.get("/apis", getCompanyInfo);
// Test email route
app.get('/send', async (req, res) => {
try {
await mailSender(
"codewithsameer786@gmail.com",
"Test Email",
"<h1>Hello World</h1>"
);
res.send("Email sent successfully!");
} catch (error) {
console.error("Error sending email:", error);
res.status(500).send("Failed to send email");
}
});
// Start server
app.listen(PORT, () => {
console.log(`Server is listening at port ${PORT}`);
});