Skip to content

Commit

Permalink
Added eslint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman-Codes committed Jan 6, 2021
1 parent 943b9d2 commit b2af939
Show file tree
Hide file tree
Showing 43 changed files with 7,724 additions and 6,106 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
/config
.DS_Store
/*.env
keys.js
/public
22 changes: 22 additions & 0 deletions .eslintrc.json
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"
}
}
24 changes: 13 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _Put an `x` in the boxes that apply_
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update (Documentation content changed)
- [ ] Other (please describe):
- [ ] Other (please describe):

## Checklist

Expand All @@ -32,4 +32,4 @@ Please attach the screenshots of the changes made in case of change in user inte

## Other information

Any other information that is important to this pull request
Any other information that is important to this pull request
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
/config
.DS_Store
/*.env
keys.js
/public
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"editor.tabSize": 2
}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Patient can choose a date and doctor to consult, the system will automatically g
Doctor on the other hand can accept/reject the appointment, view all his current and past appintment and upload detailed prescription for the patient.<br/>

## Visit Online

This website is hosted at [https://hospital-help.herokuapp.com/](https://hospital-help.herokuapp.com/)

## Getting Started
Expand Down Expand Up @@ -33,5 +34,5 @@ npm install
```
npm start
```
Go to: [http://localhost:4000](http://localhost:4000)

Go to: [http://localhost:4000](http://localhost:4000)
122 changes: 65 additions & 57 deletions app.js
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;
28 changes: 14 additions & 14 deletions docs/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Expand Down Expand Up @@ -73,4 +73,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
https://www.contributor-covenant.org/faq
14 changes: 7 additions & 7 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ We love your input! We want to make contributing to this project as easy and tra

### 1. Fork it :fork_and_knife:

You can get your own fork/copy of [HospitalWebsite]( https://github.com/Aman-Codes/HospitalWebsite) by using the <kbd><b>Fork</b></kbd></a> button.
You can get your own fork/copy of [HospitalWebsite](https://github.com/Aman-Codes/HospitalWebsite) by using the <kbd><b>Fork</b></kbd></a> button.

[![Fork Button](https://help.github.com/assets/images/help/repository/fork_button.jpg)](https://github.com/Aman-Codes/HospitalWebsite)
[![Fork Button](https://help.github.com/assets/images/help/repository/fork_button.jpg)](https://github.com/Aman-Codes/HospitalWebsite)

### 2. Clone it :busts_in_silhouette:

Expand All @@ -27,7 +27,7 @@ git clone https://github.com/Your_Username/HospitalWebsite.git

> This makes a local copy of repository in your machine.
Once you have cloned the ` HospitalWebsite ` repository in GitHub, move to that folder first using change directory command.
Once you have cloned the `HospitalWebsite` repository in GitHub, move to that folder first using change directory command.

```sh
# This will change directory to a folder HospitalWebsite
Expand All @@ -38,7 +38,7 @@ Move to this folder for all other commands.

### 3. Set it up :arrow_up:

Run the following commands to see that *your local copy* has a reference to *your forked remote repository* in GitHub :octocat:
Run the following commands to see that _your local copy_ has a reference to _your forked remote repository_ in GitHub :octocat:

```sh
git remote -v
Expand All @@ -52,7 +52,7 @@ Now, add a reference to the original [HospitalWebsite](https://github.com/Aman-C
git remote add upstream https://github.com/Aman-Codes/HospitalWebsite.git
```

> This adds a new remote named ***upstream***.
> This adds a new remote named **_upstream_**.
See the changes using

Expand All @@ -67,7 +67,7 @@ upstream https://github.com/Aman-Codes/HospitalWebsite.git (push)
### 4. Sync it :recycle:

Always keep your local copy of repository updated with the original repository.
Before making any changes and/or in an appropriate interval, run the following commands *carefully* to update your local repository.
Before making any changes and/or in an appropriate interval, run the following commands _carefully_ to update your local repository.

```sh
# Fetch all remote repositories and delete any deleted remote branches
Expand Down Expand Up @@ -131,4 +131,4 @@ Then add a title and description to your pull request that explains your preciou

Sit and relax till we review your PR, you've made your contribution to our project.

:tada: :confetti_ball: :smiley: _**Happy Contributing**_ :smiley: :confetti_ball: :tada:
:tada: :confetti*ball: :smiley: ***Happy Contributing**\_ :smiley: :confetti_ball: :tada:
Loading

0 comments on commit b2af939

Please sign in to comment.