stackvana / hook.io

Open-Source Microservice Hosting Platform
https://hook.io
Other
1.26k stars 117 forks source link

Using git inside of a microservice #278

Closed mathisonian closed 7 years ago

mathisonian commented 7 years ago

Is it possible to git clone something inside of a microservice? I'm trying to build something similar to https://bl.ocks.org/ that will take in the URL of a gist, and return the contents one of the files. In particular I'd like to be able to use http://www.nodegit.org/ or similar

Marak commented 7 years ago

Absolutely!

I think the best thing to do would be use https://www.npmjs.com/package/octonode library ( which should be installed and ready to go on hook.io )

To give you an idea on how to do it, we actually are doing this same type of functionality internally ( fetching source code from files in a gist ) using this: https://github.com/Stackvana/microcule/blob/master/lib/plugins/sourceGithubGist.js#L45

You'd just need to create a new JavaScript service which used octonode ( or any other Github API wrapper ), call the Github API, and pipe the response back to the client.

Hope that helps.

mathisonian commented 7 years ago

Awesome, thanks @Marak!