Skip to content

Commit d2e2c3e

Browse files
committed
database connected
1 parent 0584b48 commit d2e2c3e

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

login , sign-up rest api's/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
const express=require('express');
22
const mongooses= require('mongoose');
33
const User=require('./models/user');
4+
const db=require('./mysetup/myurl').myurl;
5+
const bodyparser=require('body-parser');
46

57
var app=express();
8+
// app use
9+
app.use(bodyparser.urlencoded({extended : false}));
10+
app.use(bodyparser.json());
11+
12+
// database connection
13+
mongooses.connect(db).then(()=>{
14+
console.log('databse is connected');
15+
}).catch(err=>{
16+
console.log("err is", err.message);
17+
})
18+
19+
620

721
app.get('/',function(req,res){
822
res.status(200).send(`hyy`);
923
})
1024

25+
// listening port
1126
const PORT=process.env.PORT||3000;
1227
app.listen(PORT,()=>{
1328
console.log(`app is live at ${PORT}`);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
myurl: 'mongodb://localhost:27017/Users',
3+
secret: 'mysecretkey'
4+
}

login , sign-up rest api's/node_modules/body-parser/package.json

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

login , sign-up rest api's/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12+
"body-parser": "^1.19.0",
1213
"express": "^4.17.1",
1314
"mongoose": "^5.9.19",
1415
"nodemon": "^2.0.4"

0 commit comments

Comments
 (0)