Skip to content

Commit e1c83e3

Browse files
committed
database connected
1 parent ebd0c92 commit e1c83e3

File tree

736 files changed

+65396
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

736 files changed

+65396
-1
lines changed

CRUD API's/app.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const express=require('express');
2+
const bodyparser=require('body-parser');
3+
const mongoose=require('mongoose');
4+
5+
//create express app
6+
const app=express();
7+
8+
//parse application/ x-www-form-urlencoded
9+
app.use(bodyparser.urlencoded({extended : true}));
10+
//parse application json
11+
app.use(bodyparser.json());
12+
13+
//connect the database
14+
mongoose.Promise=global.Promise;
15+
mongoose.connect('mongodb://localhost:27017/crud-api',{
16+
useNewUrlParser: true
17+
}).then(()=>{
18+
console.log("database is connected");
19+
}).catch((err)=>{
20+
console.log("could not connect to the database");
21+
process.exit();
22+
})
23+
24+
25+
app.get('/',function(req,res){
26+
res.json({"message": "welcome to crud api's"});
27+
});
28+
29+
const PORT=3000||process.env.PORT;
30+
app.listen(PORT,()=>{
31+
console.log(`app is live at ${PORT}`);
32+
});

CRUD API's/node_modules/.bin/is-ci

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

CRUD API's/node_modules/.bin/is-ci.cmd

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

CRUD API's/node_modules/.bin/is-ci.ps1

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

CRUD API's/node_modules/.bin/nodemon

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

CRUD API's/node_modules/.bin/nodemon.cmd

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

CRUD API's/node_modules/.bin/nodemon.ps1

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

CRUD API's/node_modules/.bin/nodetouch

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

CRUD API's/node_modules/.bin/nodetouch.cmd

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

CRUD API's/node_modules/.bin/nodetouch.ps1

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

0 commit comments

Comments
 (0)