-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
37 lines (30 loc) · 974 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
import "dotenv/config.js";
import "./config/database.js";
import cors from "cors";
import express from "express";
import indexRouter from "./routers/indexRouter.js";
import errorHandler from "./middlewares/errorHandler.js";
import notFoundHandler from "./middlewares/notFoundHandler.js";
// const corsOptions = {
// origin: 'http://localhost:5173/'
// }
const server = express();
server.use(cors());
server.use(express.json());
server.use("/api", indexRouter);
server.use(express.static("public"));
server.get("/", (req, res, next) => {
res.send('Welcome to my API of "MyTinerary"! (Don´t get too comfy)');
});
server.use(notFoundHandler);
server.use(errorHandler);
server.listen(process.env["PORT"], () => {
console.log(
"\x1b[42m\x1b[30m%s\x1b[0m",
"Server is running on: http://localhost:" + process.env["PORT"]
);
console.log(
"\x1b[42m\x1b[30m%s\x1b[0m",
"Server is running on: https://api-mytinerary-joetheorium.vercel.app/"
);
});