npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rapidapi

v2.0.3

Published

A docroot-like API, which lets storing & retrieving your stuff get out of your way

Downloads

8

Readme

rapidapi

Store your stuff, rapidly ... rapidapidly.

A docroot-like API, which lets storing & retrieving your stuff get out of your way.

Version 1.0 of rapidapi supported schema-less object storage with dehydrated lists - this functionality has been removed, but can still be found in branch 1.0.12

##INSTALL

  • Install node.js. Head to the node.js download page, and download and install the latest stable version.

  • In your code: (remember to replace REDIS_HOST, REDIS_PORT, and SERVER_PORT with your own config)

    var rapidapi = require ( 'rapidapi' );
    var config = {
        routeRoot: './routes'
    };

    rapidapi ( config, function ( error, server ) {
        if ( error ) {
            return console.error ( error );
        }

        console.log ( 'ready' );
    } );

Just like that, you're ready to store your stuff!

##DOCROOT model

If the docRoot attribute is provided in the configuration parameter, its value is taken to be a folder relative to rapidapi's module parent. This folder is then parsed recursively, and its contents is exposed as API endpoints, like a directory tree would be exposed on a web server.

If it is not provided, it defaults to routes.

If a file in this structure is called index.js, its associated endpoint will be the path it is in. Otherwise, the filename will act as a resource parameter, and exposed as such in the request attribute

    req.params

If more than one request parameter is needed, the filename becomes the request parameters, in order, separated by dashes.

For example:

*docRoot*/index.js -> /
*docRoot*/param1.js -> /:param1
*docRoot*/param1-param2.js -> /:param1/:param2
*docRoot*/resource/index.js -> /resource/
*docRoot*/resource/param1.js -> /resource/
*docRoot*/resource/param1-param2.js -> /resource/:param1/:param2

Files in this directory are node modules, and should export a function for each method it wants to support on the endpoint. This function (called the request handler), accepts two parameters, the request object, and a callBack function.

The callBack function accepts an error parameter as its first argument. If this error is a string, it is returned with HTTP status 500.

If any other HTTP code is to be returned, error has to be structured as follows:

    {
        type: ERRORTYPE,
        message: ERRORMESSAGE
    }

Viable error messages are:

{
    400: 'BadRequestErrorError',
    401: 'UnauthorizedError',
    402: 'PaymentRequiredError',
    403: 'ForbiddenError',
    404: 'NotFoundError',
    405: 'MethodNotAllowedError',
    406: 'NotAcceptableError',
    407: 'ProxyAuthenticationRequiredError',
    408: 'RequestTimeoutError',
    409: 'ConflictError',
    410: 'GoneError',
    411: 'LengthRequiredError',
    412: 'PreconditionFailedError',
    413: 'RequestEntityTooLargeError',
    414: 'RequestUriTooLargeError',
    415: 'UnsupportedMediaTypeError',
    416: 'RequestedRangeNotSatisfiableError',
    417: 'ExpectationFailedError',
    418: 'ImATeapotError',              // RFC 2324
    422: 'UnprocessableEntityError',    // RFC 4918
    423: 'LockedError',                 // RFC 4918
    424: 'FailedDependencyError',       // RFC 4918
    425: 'UnorderedCollectionError',    // RFC 4918
    426: 'UpgradeRequiredError',        // RFC 2817
    500: 'InternalServerErrorError',
    501: 'NotImplementedError',
    502: 'BadGatewayError',
    503: 'ServiceUnavailableError',
    504: 'GatewayTimeoutError',
    505: 'HttpVersionNotSupportedError',
    506: 'VariantAlsoNegotiatesError',  // RFC 2295
    507: 'InsufficientStorageError',    // RFC 4918
    509: 'BandwidthLimitExceededError',
    510: 'NotExtendedError'             // RFC 2774
};

Error can also be structure as such:

    {
        code: HTTPCODE,
        message: ERRORMESSAGE
    }

HTTPCODE can be replaced by an explicit HTTP code to return with the error message.

handler example:

In a file stored in docRoot/divide/numerator-denominator.js:

module.exports = {
    get: function ( req, callBack ) {
        var n = parseInt ( req.params.numerator, 10 );
        var d = parseInt ( req.params.denominator, 10 );

        if ( d === 6379 ) {
            return callBack ( {
                code: 201,
                message: 'Easter egg!'
            } );
        }

        if ( d === 0  ) {
            return callBack ( {
                type: 'NotAcceptableError',
                message: 'Divide by zero error'
            } );
        }

        return callBack ( null, n/d );
    }
};