0.4.2-nexbit.1 • Published 5 years ago

@nexbit/cuba-rest v0.4.2-nexbit.1

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
5 years ago

CUBA REST JS

Build Status

JavaScript library for web and Node.js which facilitates CUBA Platfotm's REST API usage.

Installation

npm

npm install @nexbit/cuba-rest --save

Import as module

const cuba = require('@nexbit/cuba-rest');

Or using ES6 imports:

import * as cuba from '@nexbit/cuba-rest';

Dependencies and requirements

Library has no external dependencies. It's assumed that Promise and fetch -compatible API are available or polyfilled i.e. in node environment:

npm install node-fetch --save
fetch = require('node-fetch');

Usage

import * as cuba from '@nexbit/cuba-rest';

const app = cuba.initializeApp({
  name: 'myApp',
  apiUrl: 'http://localhost:8080/app/rest/'
});

app.getUserInfo().then((d) => {
  console.log(d);
});

// retrieve app by name

const myApp = cuba.getApp('myApp');

or use if you want to manage instances yourself

const myApp = new CubaApp("myApp", "http://localhost:8080/app/rest/")
myApp.loadEntities('sec$User', {view: '_minimal', sort: 'login'}).then((users) => {
  console.log(users);
});

Full API reference

Development

Tests

In order to run integration tests you need Java to be installed.

Integration tests

npm run test:integration

Running manually

Start test CUBA app

npm run start-test-app

Run tests

npm test

Stop test app

npm run teardown-test-app

Build

npm run dist

Lint

npm run lint

Generate documentation

npm run generate-docs