0.3.1 • Published 7 years ago
@mu-cms/express-es-git v0.3.1
Express middleware for es-git
express-es-git is a v4 Express router middleware that allows you to expose an es-git repository for read over http(s).
Installation
Install express-es-git with npm
npm install --save @mu-cms/express-es-gitUsage
const git = require('@mu-cms/express-es-git');
const { SPECS, HEAD } = require('@mu-cms/express-es-git/const');
// options is/are optional
const options = {
specs: [ ref => ({}) ], // SPECS
head: data => ({}) // HEAD
};
// es-git repository instance
const repo;
// app is an express/router instance
app.use(git(repo, options));A full example can be found in mu-express.
Routes
GET/:ref\.:ext?Load by object sha1 or refGET/:ref/:path([^$]+)Load by tree sha1 or ref and pathPOST/fetchFetches refspecs from url
Examples
/testing/package.jsonLoad by tag ref/master/package.jsonLoad by head ref/0e3b9890a6af246cff7db2bd8b68ccfaba5b1c78/package.jsonLoad by tree hash/166db7d969ef2db26bbc62127a276475828384a2.jsonLoad by blob hash (with.extmime type)/166db7d969ef2db26bbc62127a276475828384a2Load by blob hash (withapplication/octet-streammime type)
curl -X POST http://127.0.0.1:8080/fetch -d 'url=https://github.com/mu-cms/mu-express.git' -d 'refs=refs/heads/*:refs/remotes/express/*'curl -X POST http://127.0.0.1:8080/refs -d 'refs=refs/heads/express:refs/remotes/express/master'