Giter Club home page Giter Club logo

kevast-gist.js's Introduction

kevast-gist.js

Build Status Coverage Status Dependencies Dev Dependencies Package Version Open Issues MIT License

A gist storage for kevast.js.

Installation

Node.js

Using yarn

yarn add kevast-gist

Using npm

npm install kevast-gist

Browser

<script src="https://cdn.jsdelivr.net/npm/kevast-gist/dist/kevast-gist.min.js"></script>

Usage

Only access token given:

const { Kevast } = require('kevast');
const { KevastGist } = require('kevast-gist');
const assert = require('assert');

const ACCESS_TOKEN = 'YOUR GITHUB ACCESS TOKEN';

(async () => {
  const kevastGist = await KevastGist.create(ACCESS_TOKEN);
  // Gist id and filename will be generated automatically
  console.log(kevastGist.getGistId());
  console.log(kevastGist.getFilename());

  const kevast = new Kevast(kevastGist);
  await kevast.set('key', 'value');
  assert(await kevast.get('key') === 'value');
})();

Access token and gist id given:

const { Kevast } = require('kevast');
const { KevastGist } = require('kevast-gist');
const assert = require('assert');

const ACCESS_TOKEN = 'YOUR GITHUB ACCESS TOKEN';
const GIST_ID = 'GIST ID';

(async () => {
  const kevastGist = await KevastGist.create(ACCESS_TOKEN, GIST_ID);
  assert(kevastGist.getGistId() === GIST_ID);
  // Filename will be generated automatically
  console.log(kevastGist.getFilename());

  const kevast = new Kevast(kevastGist);
  await kevast.set('key', 'value');
  assert(await kevast.get('key') === 'value');
})();

Access token, gist id and filename given:

const { Kevast } = require('kevast');
const { KevastGist } = require('kevast-gist');
const assert = require('assert');

const ACCESS_TOKEN = 'YOUR GITHUB ACCESS TOKEN';
const GIST_ID = 'GIST ID';
const FILENAME = 'FILE NAME';

(async () => {
  const kevastGist = await KevastGist.create(ACCESS_TOKEN, GIST_ID, FILENAME);
  assert(kevastGist.getGistId() === GIST_ID);
  assert(kevastGist.getFilename() === FILENAME);

  const kevast = new Kevast(kevastGist);
  await kevast.set('key', 'value');
  assert(await kevast.get('key') === 'value');
})();

How to get a GitHub Access Token

Click this link to generate a new GAT.

Steps:

  1. Description

The description is arbitrary. You can fill in anything you like. But kevast-gist is recommended to remind you this GAT is being used by this kevast-gist.

  1. Scopes

Kevast-gist only requires Gist scope, so please do not check other unnecessary permissions to ensure your account security.

  1. Generate

Click Generate button and you will see the newly created GAT.

ATTENTION: You won't be able to see it again. Please keep it properly, otherwise it can only be regenerated.

kevast-gist.js's People

Contributors

andiedie avatar zackyjsd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.