1.1.2 • Published 7 years ago

github-gist-db v1.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

npm version

Purpose

Use GitHub Gists as a key-value store because it is free and has a well-documented API which we can (ab)use.

Examples

git clone git@github.com:SivanMehta/github-storage.git
cd github-storage
yarn install
node examples/server-setup.js

This will require that you create a file named examples/config.json that takes the following form. You can get an access token here.

{
  "token": "YOUR-ACCESS-TOKEN"
}

Usage

yarn install github-gist-db
var gs = require('github-storage')
var db = new gs({ token: 'YOUR-GITHUB-ACCESS-TOKEN' })

Now db is an object that will interact with Github to store your data. If you plan on using some other type of authorization, you will need to provide authorization exactly like you would the github package .

MethodSpecificationDescription
db.create(dbname)returns a Promise with success true/falseCreates a datastore with the name dbname. This datastore will automatically look for your gists that match the title to the regex /.-snapshot/
db.destroy(dbname, callback)Callback with any leveldb errorsDestroys a datastore with the name dbname, provided that it's already been created
db.push(dbname, callback)Callback with (err, gistID)Connects to GitHub and either creates a gist to store the current database, or pushes the current state of the database to the corresponding gist.
db.pull(dbname, callback)Callback with (success)Connects to GitHub and replaces the current datastore with whatever is stored in its corresponding gist.
db.put(params, callback)Callback with any leveldb errorsPut a value in the datastore. params should have the values for dbname, key, and value
db.get(params, callback)Callback with any leveldb errorsGet a value from the datastore. params should have the values for dbname, key
1.1.2

7 years ago

1.1.1

7 years ago

1.0.1

7 years ago