Skip to content

Commit

Permalink
fix(server): serve dashboard from all dashboard routes
Browse files Browse the repository at this point in the history
This is temp fix so that navigating straight to a nested dashboard route
works. I had to hardcode the routes to get this working which is not a
good long term solution.
  • Loading branch information
eysi09 committed Feb 11, 2019
1 parent 06386bf commit 5abf580
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
33 changes: 33 additions & 0 deletions garden-service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions garden-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"klaw": "^3.0.0",
"koa": "^2.6.2",
"koa-bodyparser": "^4.2.1",
"koa-mount": "^4.0.0",
"koa-router": "^7.4.0",
"koa-static": "^5.0.0",
"koa-websocket": "^5.0.1",
Expand Down Expand Up @@ -113,6 +114,7 @@
"@types/klaw": "^2.1.1",
"@types/koa": "^2.0.47",
"@types/koa-bodyparser": "^4.2.1",
"@types/koa-mount": "^3.0.1",
"@types/koa-router": "^7.0.35",
"@types/koa-websocket": "^5.0.3",
"@types/lodash": "^4.14.119",
Expand Down
9 changes: 7 additions & 2 deletions garden-service/src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import chalk from "chalk"
import Koa = require("koa")
import mount = require("koa-mount")
import serve = require("koa-static")
import Router = require("koa-router")
import websockify = require("koa-websocket")
Expand Down Expand Up @@ -79,8 +80,12 @@ export async function createApp(garden: Garden, log: LogEntry) {
app.use(http.routes())
app.use(http.allowedMethods())

// TODO: Bundle the dashboard with the NPM / Zeit packages
app.use(serve(DASHBOARD_STATIC_DIR))
// This enables navigating straight to a nested route, e.g. "localhost:<PORT>/graph".
// FIXME: We need to be able to do this for any route, instead of hard coding the routes like this.
const routes = ["/", "/graph", "/logs"]
for (const route of routes) {
app.use(mount(route, serve(DASHBOARD_STATIC_DIR)))
}

addWebsocketEndpoint(app, garden, log, commands)

Expand Down

0 comments on commit 5abf580

Please sign in to comment.