-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (19 loc) · 698 Bytes
/
app.js
File metadata and controls
31 lines (19 loc) · 698 Bytes
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
const express = require('express');
const mongoose = require('mongoose');
const port = "4000";
const host = "localhost";
require('dotenv').config()
const router = require('./routes/auth');
const postRouter = require('./routes/posts')
const app = express();
mongoose.Promise = global.Promise;
mongoose.connect(process.env.CONNECTION_DB,({ useUnifiedTopology: true ,useNewUrlParser: true } ),()=>{
console.log("connect to mongodb ")
});
//API-Middlewares
app.use("/api/user", router);
app.use("/api/posts", postRouter);
// ====================Listining the server===============
app.listen(port, ()=>{
console.log(`The server is up and Running at http://${port}:${host}`);
})