Registry Mirror
搜索
Skip to content
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Files
Expand file tree
main
Breadcrumbs
Blogapp-tutorials
/
app.js
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
38 lines (28 loc) · 828 Bytes
main
Breadcrumbs
Blogapp-tutorials
/
app.js
Copy path
Top
File metadata and controls
Code
Blame
38 lines (28 loc) · 828 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require('dotenv').config();
const express=require('express');
const bodyparser=require('body-parser');
const mongoose=require('mongoose');
const cors=require('cors');
const app=express();
app.use(cors());
app.use(bodyparser.json());
app.use(bodyparser.urlencoded({extended:true}));
mongoose.Promise=global.Promise;
mongoose.connect(process.env.MONGO_URL,{ useNewUrlParser: true }).then(()=>
{console.log("DB is connected");}
).catch((err)=>{
console.log(err);
process.exit();
})
app.get('/',(req,res)=>{
res.send("Welcome to the class");
});
require('./routes/route')(app);
app.use('*',(req,res,next)=>{
res.status(404).json({"msg":"Not found"});
});
const Port=process.env.PORT||3000;
app.listen(Port,(err)=>{
if(err) console.log(err);
else console.log(`port is live at ${Port}`);
});
You can’t perform that action at this time.