-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (28 loc) · 966 Bytes
/
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
36
import { authorize } from "./src/services/gmail-services/googleApi.js";
import express from "express";
import { main } from "./server.js";
import colours from "@colors/colors"
const app = express();
const PORT = process.env.PORT || 3000;
app.get('/', (req, res) => {
res.send('Hello World'.bgBlue);
});
async function startServer() {
try {
const auth = await authorize();
console.log("Auth apikey: ", auth._clientSecret);
if(!auth) {
console.error("Error authorizing credentials");
console.log("Run 'npm run gmail' to authorize credentials".red.bold)
process.exit(1);
}
// Define your routes and middleware here
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`.bgGreen.white.bold);
main();
});
} catch (error) {
console.error("Error starting server:".red.bold.bgBlue, error);
}
}
startServer();