-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (39 loc) · 1.33 KB
/
server.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
46
47
const express = require("express");
const app = express();
// const bodyParser = require('body-parser');
// const fs = require('fs');
const morgan = require('morgan');
const cors = require("cors");
const path = require("path");
require("dotenv").config({ path: "./config.env" });
const port = process.env.PORT || 5000;
app.use(morgan('tiny'));
app.use(cors());
app.use(express.json());
app.use(require("./routes/signup"));
app.use(require("./routes/casemanagement"));
app.use(require("./routes/class8"));
app.use(require("./routes/clinicsession"));
app.use(require("./routes/counseling"));
app.use(require("./routes/schoolsession"));
app.use(require("./routes/primaryrecord"));
app.use(require("./routes/secondaryrecord"));
app.use(require("./routes/lifeskillssession"));
app.use(require("./routes/registration"));
// get driver connection
const dbo = require("./db/conn");
//Serve static assets in production
if (process.env.NODE_ENV === 'production') {
// Set static folder
app.use(express.static('client/build'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
});
}
app.listen(port, () => {
// perform a database connection when server starts
dbo.connectToServer(function (err) {
if (err) console.error(err);
});
console.log(`Server is running on port: ${port}`);
});