gbox-apis
Version:
An Gbox API's npm Package for Node.js and Sails.js
72 lines (61 loc) • 2.13 kB
Markdown
<h1 align="center">
<img width="200" src="http://gauss.hr/wp-content/themes/olympos/images/landing/logo.svg" alt="gauss"> GaussBox
</h1>
Build as support for GaussBox API. Works with Sails.js only.
New API's automatically check-in to all GaussBox API's, retrieve info about all API's and many more.
## Install
```
$ npm install --save gbox-apis
```
## Usage
Package requires database configuration on initialisation.
```js
let dbConfig = {
host: "********",
port: "********",
user: "********",
password: "********",
database: "********"
};
const Gbox = require('gbox-apis')(dbConfig);
```
For checking in, routes array must be sent.
```js
let routes = [
{
actionName: "String field, descriptive action name, user friendly. This is seen by user when creating permissions.",
action: "String field, action name, aka user_create. Multiword actions is divided by underscore.",
type: "String field. Read dev documentation for action types.",
visibility: "Array of strings, it is optional. Read dev documentation for visibility types.",
level: "Array of strings, it is optional. Read dev documentation for level types.",
controllerActions: "Array of strings, it is optional. Read dev documentation for controllerActions.",
routeVersion: "String field, route version aka v1",
routeMethod: "String field, HTTP method",
route: "String field, starts with slash and folowed by API url."
},
...
];
```
Calling checkIn method. Controller actions is optional.
```js
Gbox.checkIn(routes);
```
Getting api data with list of available actions.
```js
// to get Apis data
Gbox.getData();
```
## Dependency
To check-in API, package.json must have this properties:
```js
"name": "service-api",
"descriptiveName": "Service API",
"version": "1.0.0",
"description": "Short API description.",
```
URL to API is provided in node environment. If not set, API would be checked in with localhost IP.
```js
process.env.homepage = "127.0.0.1:2222";
```
## Created by
[Saša Mihaljenović, Gauss d.o.o.](http://gauss.hr/)