status-is-ok

    1.2.3Β β€’Β PublicΒ β€’Β Published

    Status-is-ok

    Check if the url is 200-A-Ok 🎈 NPM version NPM download count license

    Installation

    npm: npm install status-is-ok yarn: yarn add status-is-ok

    Usage

    Function

    const IsOk = require('status-is-ok')
    IsOk('http://xkcd.com')
    

    Callback

    const IsOk = require('status-is-ok')
    const isUrlOk = new IsOk()
    isUrlOk.check('http://xkcd.com', callback)
    

    Promise

    const IsOk = require('status-is-ok')
    const isUrlOk = new IsOk();
    isUrlOk.check('http://xkcd.com')
      .then(function)
      .catch(function)
    

    The module exposes just a single function:

    .check(url, [callback])
    
    • this checks the url is ok, and will return a promise or return via the callback if one is specified

    The callback and promise will return an object with the following keys:

    {
      isOk: boolean | returns false on a failure
      status: status code returned | returns 404 on a failure
      message: status message
      error: any errors encountered | empty on a successful check
    }
    

    Development

    linting yarn lint // or npm run lint running the test suite yarn test // or npm test

    Todo

    • [x] check if the requested url is 200 status (OK)
    • [x] write some tests
    • [ ] handle arrays
    • [ ] cli

    License

    MIT license

    Install

    npm i status-is-ok

    DownloadsWeekly Downloads

    16

    Version

    1.2.3

    License

    MIT

    Unpacked Size

    6.72 kB

    Total Files

    5

    Last publish

    Collaborators

    • theatlasroom