Skip to Content
0
Oct 09, 2019 at 12:47 PM

Bootstrap UI5 Classes into nodejs module

108 Views Last edit Oct 09, 2019 at 12:49 PM 2 rev

Hoping to find best practice methodology to bootstrap UI5 classes into nodejs module. I do not intend to have any visible UI or xml views. I am having trouble figuring out how to bootstrap UI5 classes into my node express routes.

I found a npm package called node-ui5 that seems to do what I'm looking for However, I'm concerned with using this package in an enterprise app because it does not seem to be actively used or updated by other developers. I also don't know if I have control over the sapui5 / openui5 version that will be loaded.

Is there a way to achieve something similar to the code snippet below by using the open-ui5 npm package directly?

Thomas Jung knows all, any tips would be very much appreciated.

'node-ui5' usage sample code to utilize ui5 classes:

require('node-ui5').then(({sap}) => {
  // use sap, for instance:
  sap.ui.require([
    'sap/ui/model/odata/v2/ODataModel'
  ], async function (ODataModel) {
    console.log('Creating ODataModel...')
    const model = new ODataModel({
      serviceUrl: 'https://services.odata.org/V2/OData/OData.svc'
    })
    await model.metadataLoaded()
    console.log('Loading products...')
    model.read('/Products', {
      success: data => {
        data.results.forEach(product => {
          console.log(product.Name.padEnd(20, ' '), product.Description)
        })
      }
    })
  })
})