-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (37 loc) · 981 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
37
38
39
40
require('dotenv').config();
const express = require("express");
const client = require("./db");
const auth = require("./auth");
const events1 = require("./events1");
const cors = require("cors");
const server = express();
client.connect((err) => {
if (err) {
console.error("connection error", err.stack);
} else {
console.log("connected");
}
});
const port = process.env.PORT || 5000;
server.use(express.json());
server.use(express.static("../frontend"));
// const corsOptions = {
// origin: ['http://localhost:5000'],
// methods: ['GET', 'POST', 'DELETE', 'UPDATE', 'PUT', 'PATCH'],
// };
// http://127.0.0.1:5500/
server.use(
cors()
// origin: "http://127.0.0.1:5500",
);
server.get("/", (req, res) => {
res.status(200).json({
message : "ok"
});
});
server.use("/api/auth", auth);
server.use("/api/events", events1);
// app.use("/api/events1", events1);
server.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});