@bemobile/fusion-builder
TypeScript icon, indicating that this package has built-in type declarations

5.2.6 • Public • Published

BE-Mobile Fusion Builder

Javascript Utility library to conveniently build output for BE-Mobile Fusion.

Installation

Add the package to the project

npm install @bemobile/fusion-builder

Usage

We recommend using the node-server, which provides a ready-to-use framework for building a NodeJS fusion server. But the fusion builder can be used without it:

Standalone

You can create a valid JSON and output it whichever way you like:

import { FusionBuilder, SoundType } from '@bemobile/fusion-builder';

const fusion = new FusionBuilder();

const page = fusion.addPage('Homepage').setTitle('Homepage');

page.addLabel('Home', 'h2').placeElement();
page.addButon('OK')
    .onClick()
    .messageDialog('You clicked OK')
    .onComplete()
    .playSound(SoundType.ERROR);

Express

import * as express from 'express';
import * as bodyParser from 'body-parser';
import { Input, SoundType, FusionBuilder } from '@bemobile/fusion-builder';

type FusionRequest = express.Request & { fusion: FusionBuilder };

const app = express();
app.use(bodyParser.json());
app.use((req: FusionRequest) => {
    req.fusion = new FusionBuilder(new Input(req.body));
});

app.post('/', (req: FusionRequest, res) => {
    req.fusion.setGlobalParameter('test', 'foobar');

    const page = req.fusion.addPage('Homepage').setTitle('Homepage');

    page.addLabel('Home', 'h2').placeElement();
    page.addButon('OK')
        .onClick()
        .messageDialog('You clicked OK')
        .onComplete()
        .playSound(SoundType.ERROR);

    res.json(req.fusion.getJsonState());
});

app.post('/post2', (req: FusionRequest, res) => {
    const page = req.fusion.addPage('Homepage').setTitle('Homepage');

    page.addLabel('Home', 'h2').placeElement();
    page.addButon('OK')
        .onClick()
        .messageDialog('You clicked OK')
        .onComplete()
        .playSound(SoundType.ERROR);

    res.json(req.fusion.getJsonState());
});

Readme

Keywords

none

Package Sidebar

Install

npm i @bemobile/fusion-builder

Weekly Downloads

4

Version

5.2.6

License

UNLICENSED

Unpacked Size

175 kB

Total Files

167

Last publish

Collaborators

  • be-mobile
  • sternitzke
  • ptitmouton