Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ethicdevs/fastify-git-server

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethicdevs/fastify-git-server

A Fastify plugin to easily make one/many Git repositories available for clone/fetch/push.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

fastify-git-server

NPM MIT License Average issue resolution time Number of open issues

A Fastify plugin to easily make one/many Git repositories available for clone/fetch/push.

Installation

$ yarn add @ethicdevs/fastify-git-server
# or
$ npm i @ethicdevs/fastify-git-server

Usage

// server.ts
import fastify from "fastify";
import fastifyGitServer, { GitServer } from "@ethicdevs/fastify-git-server";

(function main() {
  const server = fastify();

  server.register(fastifyGitServer, {
    // can be set to a path to git, else will directly call "git" from $PATH.
    gitExecutablePath: undefined,
    // a method to authorise the fact that the user can fetch/push, or not.
    authorize(repoSlug: string, credentials: GitServer.AuthCredentials) {
      if (repoSlug.toLowerCase() === "testorg/test-repo") {
        return cred.username === "test" && cred.password === "test";
      }
      return false;
    },
    // a method to resolve the repository directory on disk and its authorisation mode.
    repositoryResolver(
      repoSlug: string,
    ): PromiseLike<GitServer.RepositoryResolverResult> {
      return {
        authMode: GitServer.AuthMode.ALWAYS, // or PUSH_ONLY, or NEVER.
        gitRepositoryDir: resolve(
          "/home/git-server-user/repos/testorg/test-repo",
        ),
      };
    },
  });

  server.listen("localhost", 4200, () => {
    console.log(`Server is up and running at http://localhost:4200`);
  });
})();

Run the server like so (or build/bundle it first), and enjoy!

$ ts-node server.ts
# Server is up and running at http://localhost:4200

Now you can easily git clone/fetch/push to the repository assuming you pass the right credentials set for the right repository.

$ git clone http://localhost:4200/testorg/test-repo.git
$ cd test-repo/
$ git fetch
$ git pull --rebase
$ echo "Today is: $(date)" >> ReadMe.md
$ git commit -am 'docs(readme): add the date of today'
$ git push

License

The MIT license.

Keywords

FAQs

Package last updated on 12 Sep 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc