-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
28 lines (26 loc) · 1.09 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
"use strict"
const webpack = require('webpack')
const webpackDevMiddleware = require('webpack-dev-middleware')
const webpackHotMiddleware = require('webpack-hot-middleware')
const express = require('express')
const bodyParser = require('body-parser')
const jwtParser = require('./middleware/jwt-parser')
const port = process.env.PORT || 8080
const webpackConfig = require('./webpack.config')
const compiler = webpack(webpackConfig)
const config = require('./config')
const apiRoutes = require('./routes/api-routes')
express()
.use(express.static("static"))
.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: webpackConfig.output.publicPath }))
.use(webpackHotMiddleware(compiler))
.use(bodyParser.urlencoded({ extended: false }))
.use(bodyParser.json())
.use(jwtParser(config.secret))
.use("/api", apiRoutes)
.get("/login|codex|spells|spellbooks", (req, res) => {
res.sendFile(__dirname + '/static/index.html')
})
.listen(port, () => {
console.info("==> Listening on port %s. Open up http://localhost:%s/ in your browser.", port, port)
})