-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
57 lines (46 loc) · 1.44 KB
/
server.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
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
const express = require('express')
const r = require('rethinkdbdash')()
const bodyParser = require('body-parser')
const webpack = require('webpack')
const config = require('./build/webpack.dev.conf')
const _ = require('lodash')
const app = express()
const router = express.Router()
const compiler = webpack(config)
const jsonParser = bodyParser.json()
// app.set('views','./src/components');
app.set('view engine','vue');
//Database Connection to Rethinkdb
var connection = null;
r.connect( {host: 'localhost', port: 28015}, function(err, conn) {
if (err) throw err;
connection = conn;
})
app.get('/', (req, res) => {
console.log("---------------msg from get method---------------------");
// r.db('test').tableCreate('authors').run(connection, function(err, result) {
// if (err) throw err;
// console.log(JSON.stringify(result, null, 2));
// })
res.render('/Home')
})
// handle fallback for HTML5 history API
app.use(require('connect-history-api-fallback')())
// serve webpack bundle output
app.use(require('webpack-dev-middleware')(compiler, {
publicPath: config.output.publicPath,
stats: {
colors: true,
chunks: false
}
}))
app.use(require('webpack-hot-middleware')(compiler))
console.log("-------------msg from server js--------------------");
app.use('/api', router)
app.listen(8000, 'localhost', function (err) {
if (err) {
console.log(err)
return
}
console.log('Listening at http://localhost:8000')
})