-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapp.js
More file actions
69 lines (54 loc) · 1.96 KB
/
app.js
File metadata and controls
69 lines (54 loc) · 1.96 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
62
63
64
65
66
67
68
69
import express from 'express'
import authInitialize from './src/config/auth'
import cookieParser from 'cookie-parser'
import bodyParser from 'body-parser'
import path from 'path'
import { parseConfig, getEnv } from './src/config/config'
import webpack from 'webpack'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
import webpackConfig from './webpack.config'
import questions from './src/server/routes/questions'
import users from './src/server/routes/users'
import topics from './src/server/routes/topics'
import interviews from './src/server/routes/interviews'
const compiler = webpack(webpackConfig)
const app = express()
const router = express.Router()
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cookieParser())
if(getEnv() === 'development') {
app.use(webpackDevMiddleware(compiler, {
publicPath: webpackConfig.output.publicPath,
filename: webpackConfig.output.filename,
serverSideRender: false,
stats: {
color: true,
hash: false,
timings: true,
chunks: false,
chunkModules: false,
modules: false
}
}))
}
authInitialize(app)
app.use(express.static(__dirname + '/public/javascripts/'));
app.use(express.static(__dirname + '/public/dist/'));
app.use(express.static(__dirname + '/public/images/'));
app.use(express.static(__dirname + '/src/browser/main.js'));
app.use('/api/users', users)
app.use('/api/interviews', interviews)
app.use('/api/questions', questions)
app.use('/api/topics', topics)
/* GET home page. */
app.get('*', function(req, res, next) {
res.sendFile(path.join(__dirname, 'src/browser/index.html'))
})
// Heroku bydefault set an ENV variable called PORT=443
// so that you can access your site with https default port.
// Fallback port will be 8080; basically for pre-production test in localhost
// You will use $ npm run prod for this
app.listen(process.env.PORT || 3000);
export default app