1.0.73 • Published 3 years ago

@tsukiroku/gist v1.0.73

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Gist API

npm i @tsukiroku/gist

Docs

Initialize

Note: Account token required. See Docs

import Gist from '@tsukiroku/gist';

const gist = new Gist('token');

Create Gist

ParameterType
filesGistFile
descriptionstring
options?GistOptions

GistFile

{ 'file name': { content: 'content' }, ... },

GistOptions

{ secret: boolean, ... }

Note: secret default: true

return: Promise<ReqRet<GistResponse>>

await gist
    .create(
        {
            file_name: { content: 'File Content' },
            file_name_2: { content: 'File Content 2' },
        },
        'test file'
        // { secret: true }
    )
    .then((res) => console.log(`Gist created: ${res.data!.id}`))
    .catch((err) => console.log(err));

Get Gist

ParameterType
idnumber

return: Promise<ReqRet<GistResponse>>

await gist
    .get('gist id')
    .then((res) => console.log(`gist description: ${res.data!.description}`))
    .catch((err) => console.log(err));

Update Gist

ParameterType
idnumber
filesGistFile
descriptionstring
options?GistOptions

return: Promise<ReqRet<{}>>

Note: res.data is undefined.

await gist
    .update(
        'gist id',
        {
            file_name: { content: 'File Content' },
            file_name_2: { content: 'File Content 2' },
            file_name_3: { content: 'File Content 3' },
        },
        'test file - update'
        // { secret: true }
    )
    .then((res) => console.log(`Gist updated: ${res.status.code}`))
    .catch((err) => console.log(err));

Delete Gist

ParameterType
idnumber

return: Promise<ReqRet<{}>>

Note: res.data is undefined.

await gist
    .delete(gist_id)
    .then((res) => console.log(`Gist deleted, status: ${res.status.code}`))
    .catch((err) => console.log(err));

Status codes

ref: http_status.ts

Status codeName
200OK
201CREATED
204NO_CONTENT
304NOT_MODIFIED
400BAD_REQUEST
401UNAUTHORIZED
403FORBIDDEN
404NOT_FOUND
409CONFLICT
422VAILDATION_FAILED
500INTERNAL_SERVER_ERROR
502BAD_GATEWAY
503SERVICE_UNAVAILABLE
504GATEWAY_TIMEOUT
-1UNKNOWN

LICENSE: MIT


Click here for more information on the github gists rest API.

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.73

3 years ago

1.0.62

3 years ago

1.0.72

3 years ago

1.0.61

3 years ago

1.0.71

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago