-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
53 lines (42 loc) · 1.37 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import express from 'express'
import path from 'path'
import React from 'react'
import ReactDOMServer from 'react-dom/server'
import SiteTest from './components/testbed/SiteTest'
import EmbedTest from './components/testbed/EmbedTest'
import RenderTest from './components/testbed/RenderTest'
import config from './config'
import staticRoutes from './static-routes'
import quickreload from 'quickreload'
import capture from 'error-capture-middleware'
import serve from 'staticr/serve'
const app = express()
if (config.env === 'development') {
app.use(quickreload())
}
if (config.env === 'development') {
app.use(serve(staticRoutes))
}
if (config.env === 'development') {
app.use(capture.js())
app.use(capture.css())
}
if (config.env === 'development') {
app.use(express.static(path.join(__dirname, 'public')))
}
app.get('/debug/embeds', (req, res) => {
res.status(200).send(ReactDOMServer.renderToStaticMarkup(<EmbedTest />))
})
app.get('/debug/render', (req, res) => {
res.status(200).send(ReactDOMServer.renderToStaticMarkup(<RenderTest />))
})
app.get('/', (req, res) => {
res.redirect('/tall-og-statistikk')
})
app.get('/tall-og-statistikk*', (req, res) => {
res.status(200).send(ReactDOMServer.renderToStaticMarkup(<SiteTest />))
})
if (config.env === 'development') {
app.use(require('dev-error-handler')) // eslint-disable-line import/no-commonjs
}
export default app