Service that adds a rest api on top a git repository
Перейти к файлу
Haoran Hong b4877afe20 enable CodeQL 2022-11-18 04:47:17 +08:00
.ci enable CodeQL 2022-11-18 04:47:17 +08:00
.vscode Feature: Generate typescript SDK (#13) 2019-05-22 14:00:35 -07:00
config Feature: List git commits with pagination (#31) 2019-06-04 14:09:01 -07:00
sdk Update base image to fix security vulnerabilities. (#57) 2019-12-09 14:51:54 +08:00
src [bugfix] fetch post (#103) 2022-05-26 15:22:28 +08:00
test Fix: Concurrency issues when cloning repository (#45) 2019-06-07 11:49:01 -07:00
.dockerignore Improve dockerfile (#61) 2020-01-19 17:02:22 +08:00
.gitattributes Feature: Improve logging to contain additional properties (#38) 2019-06-06 09:33:44 -07:00
.gitignore Feature: Generate typescript SDK (#13) 2019-05-22 14:00:35 -07:00
.prettierrc.yml Feature: Initial skeleton for the app (#1) 2019-05-15 13:20:50 -07:00
Dockerfile fix secure (#104) 2022-06-30 15:30:48 +08:00
LICENSE Initial commit 2019-05-15 11:02:54 -07:00
README.md Fix quick start formatting (#56) 2019-07-23 07:41:20 -07:00
jest.config.js Feature: E2E testing (#23) 2019-05-24 11:01:09 -07:00
package-lock.json [cg] fix 20220729 (#105) 2022-07-29 17:19:56 +08:00
package.json [cg] fix 20220729 (#105) 2022-07-29 17:19:56 +08:00
swagger-spec.json Add tree route and recursive option (#52) 2019-07-23 12:47:33 -07:00
tsconfig.json fix rxjs issue (#89) 2021-12-13 14:59:50 +08:00
tslint.json Feature: Initial skeleton for the app (#1) 2019-05-15 13:20:50 -07:00

README.md

CI CD
Build Status Build Status
  • Javascript SDK https://www.npmjs.com/package/git-rest-api-sdk

Overview

This project is webserver that can be used as a docker container to provide a proxy/rest api on top of git repository. One of the goal of this is to work around github api rate limiting. The api tries to looks as similar to the github rest api.

Following apis are supported for now:

  • Commits
    • List
    • Get
    • Compare
  • Branch
    • List
  • Files
    • List
    • Get content

Quick start

docker run -d -p 3009:3009 azuredevx/git-rest-api
sleep 3 # optional: wait for container to start
curl localhost:3009/repos/github.com%2Foctocat%2FHello-World/contents/

Deploy with docker

Image: azuredevx/git-rest-api

You can configure various options using environemnt variables. See https://github.com/Azure/git-rest-api/blob/master/src/config/schema.ts

Note: There is no authentication layer yet from your service to the docker image. You should most likely use in in a contained environment(Inside a VNet or kubernetes cluster for example)

Use the API

  • Using the Javascript sdk A javascript sdk is always included and up to date with the latest version of the service.
npm install --save git-rest-api-sdk
  • Use rest api

There is a /swagger endpoint which serve the swagger UI with all the api you can use and help you figure out the available/required params.

To authenticate against the repo if its not public you have 2 options:

  • x-authorization: This needs to be in a Basic auth format(Basic base64(usename:password)). Check with the git server how you can authenticate.
  • x-github-token: This is an helper for authnetication against github api. The basic header will be generated automatically

Develop

  1. Install dependencies
npm install
  1. Run
npm start           # To run once
npm start:watch     # To run and restart when there is a change

Run in vscode

Instead of npm start run npm build:watch and in vscode press F5

Windows

  • Long path issue. libgit2(library behind nodegit) doesn't support windows long path feature. Which means some repo with long reference might not work on windows. You can test with other simpler repos on windows. You should however not use this in production on windows.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.