gpusher 📝
Git over HTTP with Push and Fetch Events
Fork of substack/pushover and strongloop-forks/strong-fork-pushover
gpusher
allows one to have control as a middleware between git
and the http
transport. It does so by providing *.git/*
routes over (req,res)
, executing rpc calls to git and then streaming back the response of such calls.
Quickstart
Fetch the package:
npm i gpusher
set up the handler:
const express = ;const gpusher = ; const port = 8000;const app = ;const repos = ; repos; appall'/*' reposhandle; app;
Clone a repository:
git clone http://localhost:8000/myrepo
Push something to there:
cd myrepoecho "hue" > file.txtgit add --all .git commit -m 'something'git push origin master
See the output in the server stdout
:
listening on 8000branch=masterrepo=8788e1576ba150daeff969e74107a9ffbfa20b1ccommit=myrepo
Use cases
Rate-limiting big pushes
The handle
function takes three arguments, being the last one an optional opts
mapping:
;
where opts
can take the following values:
// a function that takes a repository (string) and returns// a `through` function that takes a chunk and then decides what // to do with it. In order to forward the chunk into the next pipe// just `this.queue(chunk)`;opts { // return a `through` function return { this; }}
This transform
method creator allows one to inject code into the pipe stream from request
to git rpc
sitting right after the decoding
phase (when gzip
decoder is sending bytes ahead).
This way one can create a rate-limiter:
let server = http;
Performing a request and streaming the response to the client
const fs = ;const http = ; const request = ;const gpusher = ;const through2 = ;const sideband = ; const repos = ; repos; http ;