graphhopper / directions-api-js-client

JavaScript client for the GraphHopper Directions API
https://graphhopper.com/api/1/examples
108 stars 85 forks source link

Use a package management system #11

Closed boldtrn closed 7 years ago

boldtrn commented 7 years ago

I created a package.json that builds a minified JS file from the different js files. That file could be published via npmjs.com this would allow us to easily reuse the code, without copying the source files.

I haven't tried publishing it via npmjs.com as I think that the package.json should be first placed in the repository, but not sure though. So this part isn't tested, yet.

I optionally, changed the usage of the js files. The old naming like GraphHopperRouting should be still working, especially, if you only need the Routing you should be able to require it via var GraphHopperRouting = require('./GraphHopperRouting.js');. If you require the whole package, you can use the GraphHopper.Routing naming, which I think is more convenient.

I wasn't able to get the jasmine test to work with npm. We use the loadJSONFixtures which is part of jasmine-jquery. Jquery requires a browser, which does not work with npm. So I just left the test as it was.

I did not include dependencies like togeojson.js in the package json as I think this is usage specific and not necessarily required to use the js client. I think you could write the code yourself or do something completely different with the results, so this is only part of the example.

In the long term I think we should also get rid of the JQuery dependency as we only use it for the Ajax request.

WDYT?