-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
73 lines (52 loc) · 1.64 KB
/
server.js
File metadata and controls
73 lines (52 loc) · 1.64 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import * as dotenv from "dotenv";
dotenv.config();
// Keep dotenv import and config before everything else
//import express, { Application, Request, Response } from "express";
import express from "express";
import cors from "cors";
import mountRoutes from "./routes/api.routes.js";
//const express = require("express");
//const cors = require("cors");
const app = express();
//const app: Application = express();
//global.__basedir = __dirname;
var corsOptions = {
origin: "http://localhost:4200"
};
//app.use(helmet()); // needs to come before any route declaration, including cors()
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors(corsOptions));
mountRoutes(app);
//module.exports = app;
// const db = require("./app/models");
// //Connect to MongoDB database
// //TODO:
// // register to mongodb and get user/password to put in .env file
// db.mongoose
// .connect(db.url, {
// useNewUrlParser: true,
// useUnifiedTopology: true
// })
// .then(() => {
// console.log("Connected to the database");
// })
// .catch(error => {
// console.log("Cannot connect to the database", error);
// process.exit();
// });
//Default route
app.get("/", (req, res) => {
res.json({ message: "Simpl Healthcare Health and Medical Data Simulator" });
});
//app.use(errorHandler);
//require("./routes/api.routes")(app);
const PORT = process.env.PORT || 8080;
// app.listen(PORT, () => {
// console.log(`[server]: API server is running on port ${PORT}.`);
// });
app.listen(PORT, async () => {
// initialize connection to the databases
//await initDB();
console.log(`[server]: API server is running on port ${PORT}.`);
});