Helper devserver, serve static files and proxy to api/tileserver

This commit is contained in:
Tom Russell 2018-08-01 17:58:29 +01:00
parent d5654e4e1e
commit ca4e569bd1
2 changed files with 34 additions and 0 deletions

17
devserver/index.js Normal file
View File

@ -0,0 +1,17 @@
/**
* Dev server for local development
* - serve static files from frontend
* - proxy /api calls to 8081
* - proxy /tiles calls to 8082
*/
const path = require('path')
const express = require('express')
const proxy = require('express-http-proxy');
const app = express()
app.use(express.static(path.join(__dirname, '..', 'frontend')))
app.use('/api', proxy('localhost:8081'))
app.use('/tiles', proxy('localhost:8082'))
app.listen(8080, () => console.log('Dev server listening on port 8080...'))

17
devserver/package.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "cl-devserver",
"version": "1.0.0",
"description": "Development server to proxy",
"private": true,
"scripts": {
"start": "node index.js",
"debug": "DEBUG=express:* node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Tom Russell",
"license": "GPL-3.0",
"dependencies": {
"express": "^4.16.3",
"express-http-proxy": "^1.2.0"
}
}