forked from PinkFairyArmadillo/TRVLR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
61 lines (49 loc) · 1.8 KB
/
Copy pathserver.js
File metadata and controls
61 lines (49 loc) · 1.8 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const path = require('path');
const express = require('express');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
const app = express();
const mongoose = require('mongoose');
const Location = require('./server-mongoose/models/locationModel');
const locationController = require('./server-mongoose/controllers/locationController');
const yelpApi = require('./controllers/yelpApi');
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://teamwind:teamwind@ds119585.mlab.com:19585/trvlr');
mongoose.connection.once('open', (err, success) => {
if (err) console.log('NOOOOOOOO');
console.log('CONNECTED YAYYYYY');
})
// then(
// () => {console.log('SUCCESSFULLY CONNECTED!')},
// err => {console.log('ERROR CONNECTING')}
// );
// mongoose.connect('mongodb://thejozhou:database123@ds119585.mlab.com:19585/trvlr');
// mongoose.connection.once('open', () =>{
// console.log('connected')
// });
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const compiler = webpack(webpackConfig);
app.use(express.static(__dirname + '/www'));
app.use(webpackDevMiddleware(compiler, {
hot: true,
filename: 'bundle.js',
publicPath: '/',
stats: {
colors: true,
},
historyApiFallback: true,
}));
app.use(function (req, res, next){
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
})
app.get('/query', locationController.findMatches);
app.post('/creating', locationController.create);
app.get('/yelpdata:location', yelpApi.sendYelpReq);
const server = app.listen(3000, function() {
const port = server.address().port;
console.log('listening at port', port);
});