-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
37 lines (32 loc) · 945 Bytes
/
index.ts
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 from "dotenv";
import express from "express";
import { Request, Response, NextFunction } from "express";
import bodyParser from "body-parser";
import morgan from "morgan";
import compression from "compression";
import cors from "cors";
import versionrouter from "./routes/versionrouter";
import connectMongoose from "./utils/mongoconnect";
dotenv.config();
const app = express();
app.use(express.json());
app.use(compression());
app.use(bodyParser.json());
app.use(morgan("dev"));
app.use(cors());
app.use("/", versionrouter);
app.get("/", (req: Request, res: Response) => {
1;
return res.status(200).json({
message: "ReSearch Engine API",
status: 200,
data: {},
});
});
const PORT = process.env.PORT || 3000;
const URI = process.env.MONGO_URI || undefined;
app.listen(PORT, async () => {
console.log(`Server is running on port ${PORT}`);
await connectMongoose(URI as string);
console.log("Startup Complete");
});