npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

git-store

v0.5.3

Published

Git-store is koa-middleware that keeps a local copy of a remote git repository in sync, and exposes it to a read-only web api.

Downloads

1

Readme

git-store

Git-store is middleware for koa that pulls a remote git repository, and auto-updates when that repository changes. It also exposes a concise API for retrieving trees and blobs (ie. file listings and files) from that git repository at any commit in its history.

DISCLAIMER: How stable is this? Not very! This has been a side project for a few weeks and this is its maiden voyage on npm. I hope to improve and stabilize it shortly, especially adding tests, but none of that is there now so YMMV. If you find a bug, please create an issue, or better yet fix it and send a pull request my way.

How to install

To install it as a global command line utility, try:

npm install -g git-store

Or to use git-store in a specific project, install with npm like so:

npm install -D git-store

How to use as a command line tool

If you chose the global version above, the syntax is:

git-store REPO_URL

So, to create a synced git-store of this very repository, you would run:

git-store [email protected]:flimshaw/git-store.git

The repository will be cloned into the current directory in the 'store' subfolder. Eventually there will be a second argument to specify a destination for the repo, but at the moment that feature is unstable.

While this process is running, the repo will be periodically checked for updates and synced, and a web API will run at localhost:3000 that lets you query the repository in various ways.

How to use it as koa middleware

I'll initially be using this tool in a docker environment, so that's the way I've tailored the configuration process. Configuration is done by setting environment variables, so that changes to javascript can be as minimal as possible. The included example.js shows just how minimal the js configuration is at this point:

var koa = require('koa')
var app = koa()
var gitStore = require('git-store')

app.use(gitStore)

app.listen(3000)

To run this server and point to a repository of your choice, you would set the REPO environment variable before running the example, like so:

[email protected]:flimshaw/git-store.git node example.js

Or, just change the REPO environment variable in the included Dockerfile example to use this in a Docker environment.

API Queries Supported

  • /tree/:commit/:path - returns the git tree at the given path and commit in history. The commit can also be branch names and HEAD, so for example, /tree/HEAD~1/ would return the root tree of the repository one commit in the past.

  • /raw/:commit/:path - streams the file as this path and point in history

  • /gitPull - POSTs to this url will trigger a git pull, useful for GitHub webhooks

API Queries In Progress

  • /blame/:commit/:path - blame diffs for the given commit and path

  • /feed/:page - get the last 10 commits and modified files

  • /commit/:commit - retrieve info about a particular commit

How does it work?

All blobs and trees queried at a specific commit may be considered permanent, and can be cached by consumers down the road indefinitely without the need to ever check for updates. Files and trees retrieved via a branch or tag (dev, HEAD~1 etc) should be considered volatile.

Config Defaults

Port: 3000 Protocol: REST / http