-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (19 loc) · 691 Bytes
/
server.js
File metadata and controls
24 lines (19 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const express = require('express')
const app = express()
const bodyParser = require("body-parser")
const mongoose = require('mongoose')
const router = require('./routes/api')
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json());
app.use('/api', router)
// 404 NOT FOUND RESPONSE
app.use((req, res, next) => {
res.status(404).send("<h1 style='text-align: center'> Page Not Found! </h1>")
})
mongoose.connect('mongodb+srv://mudassirraza912:Mams9990!@cluster0.ywq4h.mongodb.net/Cluster0?retryWrites=true&w=majority')
.then((result) => {
app.listen(3000, () => {
console.log("Listing on 3000")
})
})
.catch((err) => console.log("err err", err))