-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
22 lines (18 loc) · 817 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const app = express();
mongoose.Promise = global.Promise;
mongoose.connect("mongodb://localhost/player_database"
,{ useNewUrlParser: true });//the collection name is player_database
mongoose.connection.once("open",function(){
console.log("connection is confirmed");
}).on("error",function(error){
console.log("error in connction: ",error);
});
const player = require("./routes/player.route.js");
app.use(bodyParser.json());//to handle the json format
app.use(bodyParser.urlencoded({extended: false}));
app.use("/players",player);// the url starts with /players and is directed to player.router.js
app.listen(3000);
console.log("successfully connected to port 3000!!!");