-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
87 lines (73 loc) · 2.86 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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* The app.js file contains the core processes
* that create the different features of the
* Mayo Clinic Patient Care Management system
* (PCM) web application. The file is, in
* essence, the server code that connects to the
* SQL database as well as handles different
* requests to the web application. Given the
* numerous lines of code in this file, sections
* have been used to break apart the different
* functionalities. To understand the code, read
* the comments throughout the app.js file and
* analyze the information section by section.
*
* Project: Mayo Clinic (PCM) Web Application
* Author: Andrew Krause
* Class: CS 364
* Date: 5/10/2022
*
*/
//jshint esversion:6
/* SECTION: INSTALLED PACKAGES AND INITIALIZATION */
// Require packages for the server that were installed.
const express = require("express");
var path = require("path");
const ejs = require("ejs");
const _ = require("lodash");
// Require additional security packages for login information
const session = require('express-session');
const passport = require("passport");
var path = require('path');
// Require packages for error checks and sessions.
var cookieParser = require('cookie-parser');
var logger = require('morgan'); // --> WHAT IS THIS???
var expressValidator = require('express-validator');
// Utilize the body parser package.
var bodyParser = require('body-parser');
// Use the file and error packages.
const { appendFile } = require("fs");
var createError = require('http-errors');
// Create web app using express. Set view engine to EJS.
// Utilize the body parser packages to parse data.
const app = express();
app.use(express.static("public"));
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
// Add modules for the web application here.
const homeRoutes = require('./routes/home-about.js');
const viewRoutes = require('./routes/views.js');
const departmentRoutes = require('./routes/departments.js');
const patientRoutes = require('./routes/patients.js');
const providerRoutes = require('./routes/providers.js');
const treatmentRoutes = require('./routes/treatments.js');
const statisticsRoutes = require('./routes/statistics.js');
/* SECTION: INCLUDE ROUTE MODULES */
// Use the route modules via app.use() below.
// We use the database route in the other files.
app.use('/', homeRoutes);
app.use('/', viewRoutes);
app.use('/', departmentRoutes);
app.use('/', patientRoutes);
app.use('/', providerRoutes);
app.use('/', treatmentRoutes);
app.use('/', statisticsRoutes);
/* SECTION: LISTEN FOR SERVER REQUESTS */
// Create a variable for listening on a port
// for Heroku or on the localhost port 3000.
const port = process.env.PORT || 3000;
// Begin listening for server requests on port 3000.
app.listen(port, function() {
console.log("Server for Mayo Clinic Patient Care Manager (PCM) Web App started on port 3000.");
});