npm.io
0.9.2 • Published 4 years ago

@haulmont/jmix-rest

Licence
Apache-2.0
Version
0.9.2
Deps
0
Size
155 kB
Vulns
0
Weekly
0
Stars
16

Jmix REST

Build Status

JavaScript library for web and Node.js which facilitates Jmix REST API usage.

Installation

npm

npm install @haulmont/jmix-rest --save

Import as module

const jmixRest = require('@haulmont/jmix-rest');

Or using ES6 imports:

import * as jmixRest from '@haulmont/jmix-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
global.fetch = require('node-fetch');

Usage

import * as jmix from '@haulmont/jmix-rest';

const app = jmix.initializeApp({
  name: 'myApp',
  apiUrl: 'http://localhost:8080/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 JmixRestConnection("myApp", "/rest/")
myApp.loadEntities('sec$User', {view: '_instance_name', 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