kevast-gist
v0.1.4
Published
Gist storage for kevast.js
Downloads
18
Maintainers
Readme
kevast-gist.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:
- 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.
- Scopes
Kevast-gist only requires Gist scope, so please do not check other unnecessary permissions to ensure your account security.
- 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.