remote-git-storage

1.0.1 • Public • Published

remote-git-storage

npm Version JS Standard

Easy data storage using Git hosting service.

Requirements

Install

$ npm install remote-git-storage

Usage

It's simple.

const RemoteStorage = require('remote-git-storage')
 
async function example () {
  const storage = RemoteStorage({
    owner: 'github-repository-owner',
    repo: 'github-repository-name',
    // Access token must not be known by others.
    token: 'access-token',
    // If you need, you can encrypt data file by commonKey.
    // Of course this must not be known by others too.
    commonKey: '1851565a02261638ab14f1d38eb1adc31100500a'
  })
 
  // Ref has a unique path.
  // The path means a JSON file path in the repository.
  const ToDo = await storage.ref('users/1/todo')
 
  // Save as a JSON file.
  // Supported type: string, number, boolean, null
  await ToDo.save([
    {
      text: 'To meet my dad',
      done: false,
      createdAt: String(new Date()), // Date type is not supported.
      impotant: 10
    }
  ])
 
  // Load the saved object
  const todos = await ToDo.load()
  console.log(todos)
  // [ { text: 'To meet my dad',
  //   done: false,
  //   createdAt: 'Sun Jul 23 2017 11:27:32 GMT+0900 (JST)',
  //   impotant: 10 } ]
}
 
example()
 

License

This software is released under the MIT License.

Links

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i remote-git-storage

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • fuji_haruka