forked from Blockstream/esplora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
27 lines (19 loc) · 816 Bytes
/
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
import fs from 'fs'
import pug from 'pug'
import path from 'path'
import express from 'express'
import browserify from 'browserify-middleware'
import cssjanus from 'cssjanus'
const rpath = p => path.join(__dirname, p)
const app = express()
app.engine('pug', pug.__express)
app.use(require('morgan')('dev'))
app.get('/', (req, res) => res.render(rpath('index.pug')))
app.get('/app.js', browserify(rpath('client/app.js')))
app.get('/style-rtl.css', (req, res) =>
res.type('css').send(cssjanus.transform(fs.readFileSync(rpath('www/style.css')).toString(), false, true)))
app.use('/', express.static(rpath('www')))
app.use((req, res) => res.render(rpath('index.pug')))
app.listen(process.env.PORT || 5000, function(){
console.log(`HTTP server running on ${this.address().address}:${this.address().port}`)
})