-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
943b9d2
commit b2af939
Showing
43 changed files
with
7,724 additions
and
6,106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/node_modules | ||
/config | ||
.DS_Store | ||
/*.env | ||
keys.js | ||
/public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"commonjs": true, | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"airbnb-base", | ||
"plugin:prettier/recommended" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 12 | ||
}, | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"linebreak-style": 0, | ||
"no-console": "off", | ||
"no-underscore-dangle": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/node_modules | ||
/config | ||
.DS_Store | ||
/*.env | ||
keys.js | ||
/public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"editor.tabSize": 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,96 @@ | ||
const localStrategy = require('passport-local'), | ||
methodOverride = require('method-override'), | ||
bodyParser = require('body-parser'), | ||
passport = require('passport'), | ||
mongoose = require('mongoose'), | ||
express = require('express'), | ||
app = express(), | ||
helmet = require('helmet'), | ||
Patient = require("./models/patient"), | ||
Doctor = require("./models/doctor"), | ||
AmbulanceRegistration = require("./models/ambulanceregistration"), | ||
IndexRoutes = require("./routes/index"), | ||
PatientRoutes = require("./routes/patient"), | ||
DoctorRoutes = require("./routes/doctor"), | ||
AmbulanceRoutes = require("./routes/ambulance"), | ||
session = require('cookie-session'), | ||
compression = require('compression'); | ||
const LocalStrategy = require('passport-local'); | ||
const methodOverride = require('method-override'); | ||
const bodyParser = require('body-parser'); | ||
const passport = require('passport'); | ||
const mongoose = require('mongoose'); | ||
const express = require('express'); | ||
const session = require('cookie-session'); | ||
const compression = require('compression'); | ||
const Patient = require('./models/patient'); | ||
const Doctor = require('./models/doctor'); | ||
const AmbulanceRegistration = require('./models/ambulanceregistration'); | ||
const IndexRoutes = require('./routes/index'); | ||
const PatientRoutes = require('./routes/patient'); | ||
const DoctorRoutes = require('./routes/doctor'); | ||
const AmbulanceRoutes = require('./routes/ambulance'); | ||
|
||
const app = express(); | ||
|
||
require('dotenv').config(); | ||
|
||
app.use(compression()); | ||
app.use(helmet()); | ||
if(process.env.NODE_ENV === 'production') { | ||
mongoose.connect( process.env.MONGODB_URL ,{ | ||
useUnifiedTopology: true,useNewUrlParser:true , | ||
useFindAndModify: false | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
mongoose.connect(process.env.MONGODB_URL, { | ||
useUnifiedTopology: true, | ||
useNewUrlParser: true, | ||
useFindAndModify: false, | ||
}); | ||
} | ||
else { | ||
mongoose.connect( "mongodb://localhost/medbuddy" ,{ | ||
useUnifiedTopology: true,useNewUrlParser:true , | ||
useFindAndModify: false | ||
} else { | ||
mongoose.connect('mongodb://localhost/medbuddy', { | ||
useUnifiedTopology: true, | ||
useNewUrlParser: true, | ||
useFindAndModify: false, | ||
}); | ||
} | ||
|
||
|
||
app.use(express.static(__dirname + '/public')); | ||
app.set("view engine", "ejs"); | ||
app.use(bodyParser.urlencoded({extended: true, useNewUrlParser:true})); | ||
app.use(express.static(`${__dirname}/public`)); | ||
app.set('view engine', 'ejs'); | ||
app.use(bodyParser.urlencoded({ extended: true, useNewUrlParser: true })); | ||
app.use(methodOverride('_method')); | ||
|
||
// PASSPORT CONFIGURATION // | ||
app.use(session({ | ||
secret: "Project MedBuddy is Awesome!", | ||
app.use( | ||
session({ | ||
secret: 'Project MedBuddy is Awesome!', | ||
resave: false, | ||
saveUninitialized: false | ||
})); | ||
saveUninitialized: false, | ||
}) | ||
); | ||
|
||
app.use(passport.initialize()); | ||
app.use(passport.session()); | ||
|
||
passport.use('doctorlocal', new localStrategy(Doctor.authenticate())); | ||
passport.use('patientlocal', new localStrategy(Patient.authenticate())); | ||
passport.use('ambulancereglocal', new localStrategy(AmbulanceRegistration.authenticate())); | ||
passport.use('doctorlocal', new LocalStrategy(Doctor.authenticate())); | ||
passport.use('patientlocal', new LocalStrategy(Patient.authenticate())); | ||
passport.use( | ||
'ambulancereglocal', | ||
new LocalStrategy(AmbulanceRegistration.authenticate()) | ||
); | ||
|
||
passport.serializeUser(function(user, done) { | ||
done(null, user.id); | ||
passport.serializeUser((user, done) => { | ||
done(null, user.id); | ||
}); | ||
|
||
passport.deserializeUser(function(id, done) { | ||
Patient.findById(id, function(err, Patient) { | ||
if (err) return done(err); | ||
if (Patient) return done(null, Patient); | ||
Doctor.findById(id, function(err, Doctor) { | ||
if (err) return done(err); | ||
if (Doctor) return done(null, Doctor); | ||
AmbulanceRegistration.findById(id, function(err, AmbulanceRegistration) { | ||
if (err) return done(err); | ||
if (AmbulanceRegistration) return done(null, AmbulanceRegistration); | ||
}); | ||
}); | ||
passport.deserializeUser((id, done) => { | ||
Patient.findById(id, (err, patient) => { | ||
if (err) return done(err); | ||
if (patient) return done(null, patient); | ||
Doctor.findById(id, (error, doctor) => { | ||
if (error) return done(error); | ||
if (doctor) return done(null, doctor); | ||
AmbulanceRegistration.findById(id, (e, ambulanceRegistration) => { | ||
if (e) return done(e); | ||
if (ambulanceRegistration) return done(null, ambulanceRegistration); | ||
return done(e); | ||
}); | ||
return done(error); | ||
}); | ||
return done(err); | ||
}); | ||
}); | ||
|
||
app.use(IndexRoutes); | ||
app.use(PatientRoutes); | ||
app.use(DoctorRoutes); | ||
app.use(AmbulanceRoutes); | ||
app.use(function(req,res){ | ||
res.status(404).render("404"); | ||
app.use((req, res) => { | ||
res.status(404).render('404'); | ||
}); | ||
|
||
var port = process.env.PORT || 4000; | ||
const port = process.env.PORT || 4000; | ||
app.listen(port, () => { | ||
console.log('Server running'); | ||
console.log('Server running'); | ||
}); | ||
|
||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.