-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
39 lines (30 loc) · 940 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
30
31
32
33
34
35
36
37
38
39
// Module dependencies
const webpack = require('webpack')
const express = require('express')
const path = require('path')
const port = 3000
var webpackDevMiddleware = require("webpack-dev-middleware")
const config = require('./webpack.config.js')
const app = express()
const compiler = webpack(config)
// index file to render
const index = path.join(__dirname, './public/index.html')
app.use(webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath
}))
// Static files
app.use('/public', express.static(path.join(__dirname, 'public')))
// Home route
app.get('/', function (req, res) {
res.sendFile(index)
})
// api routes
app.use('/api', require('./api/apiSearch'))
// 404
app.get('*', function (req, res) {
res.sendFile(index)
})
// Listen to...
var server = app.listen(port, function () {
console.log('- MeliTest app listening at %s on port %s!', server.address().address, server.address().port);
})