1.0.11 • Published 1 year ago

quick-status v1.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Quick-Status codes for Node.js

Utility to interact with HTTP status codes.

Example usage

IntelliSense will help quick seaching for status codes and messages. Build Status

const qs = require('quick-status');
//import { qs } from 'quick-status';

//...

    try {
        console.log(qs.INSUFFICIENT_SPACE_ON_RESOURCE_419);  //output: 419
        console.log(qs.no.419);  //=>  419

        console.log(qs.msg.INSUFFICIENT_SPACE_ON_RESOURCE_419);  //=> 'Insufficient Space on Resource'
        console.log(qs.msg.no.419);  //=> 'Insufficient Space on Resource'

        throw new Error(qs.msg.INSUFFICIENT_SPACE_ON_RESOURCE_419);
        //send  'Insufficient Space on Resource' to constructor of Error class

    } catch (err) {   //if typescript use:  catch(err: any)
        console.log(err.message);  //=>: 'Insufficient Space on Resource'
        console.log(qs.msg.getCode(err.message));  //=> 419
        console.log(qs.msg.slugify(err.message));  //=> 'Insufficient_Space_on_Resource'
        console.log(qs.msg.SLUGIFY(err.message));  //=> 'INSUFFICIENT_SPACE_ON_RESOURCE'
        console.log(qs.msg.slugify(err.message, '/'));  //=> 'Insufficient/Space/on/Resource'
        console.log(qs.msg.SLUGIFY(err.message, '/'));  //=> 'INSUFFICIENT/SPACE/ON/RESOURCE'
        throw err;
    }

Example usage

If you would not like to use qs for object name, you may use QuickStatus Class(Singleton) and naming it by yourself.

import QuickStatus from 'quick-status';

const yourVarName = new QuickStatus().getReadOnlyCode();
console.log(yourVarName.INSUFFICIENT_SPACE_ON_RESOURCE_419);
1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago