-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
39 lines (31 loc) · 943 Bytes
/
app.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
import express from "express";
import cors from "cors";
import logger from "./utils/logger.js";
import httpLogger from "./middlewares/httpLogger.js";
import literatureRouter from "./routes/literature.js";
import healthRouter from "./routes/health.js";
import { normalizePort, isProduction, isDevelopment } from "./utils/index.js";
const port = normalizePort(process.env.PORT || "8080");
const app = express();
app.use(httpLogger);
app.use(express.json());
if (isDevelopment) {
app.use(cors());
}
if (isProduction) {
app.use(
cors({
origin: [
"https://partner-platform.opentargets.org",
"https://partner-platform.dev.opentargets.xyz",
"https://platform.opentargets.org",
"https://platform.dev.opentargets.xyz",
],
})
);
}
app.use("/literature", literatureRouter);
app.use("/health", healthRouter);
app.listen(port, () => {
logger.info(`Server listening on port ${port}`);
});