Giter Site home page Giter Site logo

yulmwu-archive / gist Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 71 KB

Asynchronous gist API wrapper

Home Page: https://www.npmjs.com/package/@tsukiroku/gist

License: MIT License

TypeScript 100.00%
gist api-wrapper gist-api gist-rest-api gist-wrapper

gist's Introduction

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

Parameter Type
files GistFile
description string
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

Parameter Type
id number

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

Parameter Type
id number
files GistFile
description string
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

Parameter Type
id number

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 code Name
200 OK
201 CREATED
204 NO_CONTENT
304 NOT_MODIFIED
400 BAD_REQUEST
401 UNAUTHORIZED
403 FORBIDDEN
404 NOT_FOUND
409 CONFLICT
422 VAILDATION_FAILED
500 INTERNAL_SERVER_ERROR
502 BAD_GATEWAY
503 SERVICE_UNAVAILABLE
504 GATEWAY_TIMEOUT
-1 UNKNOWN

LICENSE: MIT


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

gist's People

Watchers

 avatar Kim Jun Young avatar

gist's Issues

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.