-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
29 lines (24 loc) · 1004 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
23
24
25
26
27
28
29
var express = require('express')
var mongoose = require('mongoose')
var bodyParser = require('body-parser')
// var itemRouter = require('./routers/item');
var auctionRouter = require('./routers/auction')
var app = express();
var PORT = 8080;
var HOST_NAME = 'mongodb+srv://bidify:Bidify1!@cluster0.ksdef.mongodb.net/Bidify?retryWrites=true&w=majority';
// var DATABASE_NAME = 'Bidify';
mongoose.connect(HOST_NAME).catch(error => console.error("error", error.message));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*"); // update to match the domain you will make the request from
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
next();
});
app.use('/api', auctionRouter);
app.listen(PORT, function () {
console.log('Listening on port ' + PORT);
});