# rapidapi-ollie

> (Temporary forker from rapidapi by Adriaan Pelzer ) A docroot-like API, which lets storing & retrieving your stuff get out of your way

Latest version **1.1.14** (published 2018-12-04) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install rapidapi-ollie
pnpm add rapidapi-ollie
yarn add rapidapi-ollie
bun add rapidapi-ollie
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.14 |
| Published | 2018-12-04 |
| First published | 2017-05-12 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 31.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Oliver Edgington |
| Maintainers | ollieedge |
| Keywords | REST, API |

## Links

- npm: https://www.npmjs.com/package/rapidapi-ollie
- Repository: https://github.com/OllieEdge/rapidapi
- Homepage: https://github.com/OllieEdge/rapidapi#readme
- Issues: https://github.com/OllieEdge/rapidapi/issues
- npm.io page: https://npm.io/package/rapidapi-ollie

## Dependencies (8)

- [path](https://npm.io/package/path.md) ^0.12.7
- [ramda](https://npm.io/package/ramda.md) ^0.18.0
- [restify](https://npm.io/package/restify.md) ^4.0.3
- [highland](https://npm.io/package/highland.md) ^2.5.1
- [inspect-log](https://npm.io/package/inspect-log.md) 0.0.3
- [client-sessions](https://npm.io/package/client-sessions.md) ^0.8.0
- [recursive-readdir](https://npm.io/package/recursive-readdir.md) ^1.3.0
- [restify-cors-middleware](https://npm.io/package/restify-cors-middleware.md) ^1.1.1

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.1.14 (latest) — 2018-12-04
- 1.1.13 — 2018-11-27
- 1.1.12 — 2018-06-14
- 1.1.2 — 2018-06-14
- 1.1.11 — 2018-06-14
- 1.1.1 — 2018-06-14
- 1.1.0 — 2018-06-14
- 1.0.9 — 2018-06-14
- 1.0.8 — 2018-06-14
- 1.0.7 — 2018-06-13
- 1.0.6 — 2018-06-13
- 1.0.5 — 2018-06-13
- 1.0.4 — 2018-06-13
- 1.0.3 — 2017-09-01
- 1.0.2 — 2017-08-07
- … 2 more at https://npm.io/package/rapidapi-ollie/versions

## README

rapidapi
========

Store your stuff, rapidly ... rapidapidly.
---------------------------------------

*A docroot-like API, which lets storing &amp; 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](http://nodejs.org/download/), 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 );
    }
};
```

---
_Source: https://npm.io/package/rapidapi-ollie · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
