-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (27 loc) · 978 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
const express = require("express");
const app = express();
const dotenv = require("dotenv");
const cookieParser = require("cookie-parser");
const next = require("next");
dotenv.config({ path: "./.env.local" });
const dev = process.env.NODE_ENV != "production";
const nextServer = next({ dev });
const handle = nextServer.getRequestHandler();
const coinMarketCapRoute = require("./Api/Routes/ApiRoutes");
// const postRoute = require("./Api/routes/posts");
const path = require("path");
const { errorHandler } = require("./Api/Middlewares/Error");
const port = process.env.PORT || 3000;
app.use(express.json());
app.use(cookieParser());
app.use("/uploads", express.static(path.join(__dirname, "uploads")));
app.use("/api/cryptocurrency", coinMarketCapRoute);
app.use(errorHandler);
nextServer.prepare().then(() => {
app.get("*", (req, res) => {
return handle(req, res);
});
app.listen(port, () => {
console.log(`App running on port ${port}....`);
});
});