forked from opentargets/ot-ai-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
45 lines (37 loc) · 1.02 KB
/
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
40
41
42
43
44
45
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({limit: '50mb'}));
if (isDevelopment) {
app.use(cors({
origin: [
process.env.SERVER_NAME,
]
}
));
}
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",
process.env.SERVER_NAME
],
})
);
}
app.use("/literature", literatureRouter);
app.use("/health", healthRouter);
app.listen(port, () => {
logger.info(`Server listening on port ${port}`);
});