Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ There can be 2 types of Users
URL: ` http://localhost:8000/api/v1`

#### End Points:
1. `/doctor/register`(POST): Register the new doctor using name,email and password(all requireds).
1. `/doctors/register`(POST): Register the new doctor using name,email and password(all requireds).
- INPUT:

![](/Images/1.JPG)
Expand All @@ -36,7 +36,7 @@ URL: ` http://localhost:8000/api/v1`

![](/Images/2.JPG)

2. `/doctor/login`(POST): Doctor can Login using email and password.
2. `/doctors/login`(POST): Doctor can Login using email and password.

- INPUT:

Expand Down
8 changes: 6 additions & 2 deletions config/mongoose.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/HospitalAPI',{useNewUrlParser: true});
const connection = "mongodb+srv://souvikmukherjee089:Souvik12345@hospital-api-cluster.5ppzfch.mongodb.net/?retryWrites=true&w=majority";

// mongoose.connect('mongodb://127.0.0.1/HospitalAPI',{useNewUrlParser: true});

mongoose.connect(connection, { useNewUrlParser: true });

const db = mongoose.connection;

db.on('error', console.error.bind(console, "Error connecting to MongoDB"));

db.once('open', function(){
db.once('open', function () {
console.log('Connected to Database :: MongoDB');
});

Expand Down
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const express=require('express');
const express = require('express');
const app = express();
const port = 8000;
const port = process.env.PORT || 9000;

const db = require('./config/mongoose');

Expand All @@ -14,28 +14,28 @@ const morgan = require("morgan");
//require passport and JWT Strategy for auth
const passport = require('passport');
//use of JWT token
const passportJWT=require('./config/passport-jwt-strategy');
const passportJWT = require('./config/passport-jwt-strategy');

//do not show the log for test
if (config.util.getEnv("NODE_ENV") !== "test") {
//use of morgan library for command line
app.use(morgan("combined"));
}
}


//parse application/json and look for raw text
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.text());
app.use(bodyParser.json({ type:"application/json" }));
app.use(bodyParser.json({ type: "application/json" }));

app.use(passport.initialize());
//use express router
app.use('/',require('./routes/index'));
app.use('/', require('./routes/index'));

//server running on port 8000
app.listen(port, function(err){
if (err){
//server running on port 9000
app.listen(port, function (err) {
if (err) {
console.log(`Error in running the server: ${err}`);
}
console.log(`Server is running on port: ${port}`);
Expand Down
Loading