-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
33 lines (27 loc) · 812 Bytes
/
server.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
import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
import sgMail from '@sendgrid/mail';
import dotenv from 'dotenv';
// import { httpLogger } from './utills/httpLogger.js';
import { router } from './router.js';
// import serverless from "serverless-http";
const app = express();
const port = 3001;
// Middleware
dotenv.config();
app.use(cors());
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
// if (process.env.NODE_ENV === 'production') {
// app.use(httpLogger);
// }
// Route for sending emails
sgMail.setApiKey(process.env.SENDGRID_API_KEY.trim());
app.use(router);
// Start the server
// export const handler = serverless(app);
app.listen(port, () => {
console.log('server started on port ', port);
});
export default app;