Sign In

git-rest-api

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-rest-api

A library providing a restful Git API mimicking as most as possible the old good git

latest
Source
npmnpm
Version
0.2.8
Version published
Weekly downloads
18
-10%
Maintainers
1
Weekly downloads
 
Created
Source

GIT REST API

Build Status

The aim of the project is to provide a restful Git API that mimics as most as possible the old good git.

For example, in order to commit a change in shell you should do:

$ mkdir new-project
$ cd new-project
$ git init
$ git add file.c
$ git commit -m 'A commit message'
$ git add file.c
$ git commit -m 'A second commit message'
$ git show HEAD~:file.c

In case of git-rest-api you should do:

POST /init
  { "repo": "new-project" }
POST /repo/new-project/tree/file.c
POST /repo/new-project/commit
  { "message": "A commit message" }
POST /repo/new-project/tree/file.c
POST /repo/new-project/commit
  { "message": "A second commit message" }
GET  /repo/new-project/show/file.c?rev=HEAD~

Install

In your project install git-rest-api and express:

$ npm install git-rest-api
$ npm install express

Environment variables

The following environment variables are supported:

  • PORT: port to serve at, default is 8080
  • PREFIX: string prefix to serve repositories at, i.e. http://localhost:[port]/[prefix]/repo/:repo/tree/:path
  • TMPDIR: name of temporary directory to use to cache repositories
  • LOGLEVEL: log level for winston logger. Default is error

Example servers

Example 1: A simple example of a server running git-rest-api:

var app = require('express')(),
    git = require('git-rest-api');

git.init(app, { installMiddleware: true }).then(function () {
  app.listen(8080);
  console.log('Listening on', 8080);
});

Example 2: All actions on repositories are specific to the client session. To share repositories between sessions/cookies, pass an existing path to workDir in the init config, e.g.

mkdirp = require('mkdirp');
var WRKDIR = './wrk-test-git';
mkdirp.sync(WRKDIR, 0755);
git.init(app, { workDir: WRKDIR }).then(function () {
  ...
});

Example 3: For a dockerized version, check docker-node-git-rest-api

Example clients

Testing

  • For direct testing on your local machine: npm install followed by npm test
  • For using the provided vagrant virtual environment: cd vagrant followed by make
  • To increase verbosity: export LOGLEVEL=info

API

Keywords

git

FAQs

Package last updated on 21 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts