koopjs / koop

Transform, query, and download geospatial data on the web.
http://koopjs.github.io
Other
654 stars 125 forks source link

Update shared map code from koop to support non root mount points #167

Closed sirws closed 7 years ago

sirws commented 9 years ago

From previous issue (https://github.com/Esri/koop/issues/142), making a new issue.

Also, may also want to make /koop/status route part of koop.

"when I visit this URL: http://50.18.49.187/koop/github the map doesn't seem to load properly because there is a request being sent to: http://50.18.49.187/js/map.js that is returning a 404..."

"The github map issue is probably an issue we need to deal with. I'll have to look at it but its trying to pull some shared code from from koop that should proably be controlled in the middleware so it respects the non root mount points. Will make a new issue."

ungoldman commented 8 years ago

Thanks for reporting this @sirws. There is a faulty assumption in the current design that koop will always be mounted at /. I'm working on making the mount point less of an issue -- koop is at least logging where it's mounted now (index.js#L329-L331).

Each provider implements the preview route separately (another issue) and is trying to access /js/map.js from the root of the domain. Koop does serve map.js in the right place (e.g. http://localhost:3000/koop/js/map.js if mounted at /koop). We'll need to change the way the preview view points to that code in each provider until preview routes are centralized. I'm hoping to make that a plugin that adds preview routes to each provider dynamically in the future.

dmfenton commented 7 years ago

Here's an example server where I've mounted koop at /koop in Koop 3.0


//clean shutdown
process.on('SIGINT', () => process.exit(0))
process.on('SIGTERM', () => process.exit(0))

// Initialize Koop
const Koop = require('koop')
const koop = new Koop()

// Install the Yelp Provider
const yelp = require('yelp')
koop.register(yelp)

// Start listening for http traffic
const config = require('config')
const port = config.port || 8080
const express = require('express')
const app = express()
app.use('/koop', koop.server)
app.listen(port)
console.log(`Koop Yelp listening on ${port}`)