Webcom library
npm install webcomWebcom is the Orange Backend-as-a-Service / Serverless
solution. It provides integrated functions for:
- database,
- message exchange (publish / subscribe),
- notification on mobile devices,
- authentication federation,
- data exposure and access control.
This platform drastically reduces time and cost to implement and deploy mobile and web applications in production.
More information on https://datasync.orange.com.
#### Webcom documentation
#### Webcom SDKs news on Plazza
#### Samples for ServerlessDb-based Web Applications
#### Changelog
Several flavors of the javascript SDK are available within the Webcom package, you must select the right one depending on your execution environment and the service(s) you need. The file name must guide you in your choice:
- With a -node suffix the library is built for a Node.js environment, otherwise it targets a Web application.
- With an -auth, a -rxdb or a -sldb suffix the library embeds respectively the
Authentication, ReactiveDb or the
ServerlessDb service (a light version of this service, without the realtime
subscription capabilities also exists with the -sldbLite suffix).
- With a -debug suffix the library is usable during your development for debugging purpose (warning:
footprint of such a library flavor is much larger, as it is neither compressed nor optimized).
- The webcom.js and webcom-node.js libraries are versions that embed all services and all APIs,
including the deprecated ones.
Examples:
``js`
// for Web Application
webcom.js // the full version including all deprecated APIs
webcom-auth-rxdb.js // a version with Authentication and ReactiveDb services
// for NodeJs based servers
webcom-node.js // the full version including all deprecated APIs
webcom-auth-sldbLite-node.js // a version with Authentication and the lite version of ServerlessDb service
#### 4.a Web applications, directly
`html`
#### 4.b Web applications, with npm
First install the Webcom package
`shell script`
npm install webcom@3.12.0
And then reference the installed javascript library in your web application:
- either with a script tag`html`import
- or with a javascript directive`javascript`
import 'webcom/webcom.js';
#### 4.c Node.js applications
First install the Webcom package
`shell script`
npm install webcom@3.12.0
And then load the javascript library in your Node.js application
`javascript`
const Webcom = require('webcom');
#### 5.a Create a reference to your Webcom application
`javascript`
const myApp = Webcom.App('
The Authentication ReactiveDb and ServerlessDb services may then be accessed respectively through the
myApp.authentication, myApp.reactiveDb and myApp.serverlessDb properties.
#### 5.b Listen to data within your data tree (ServerlessDb example)
`javascript`
const node = myApp.serverlessDb.rootNode.relativeNode("the/targeted/path");
node.subscribe(Webcom.Event.ValueChange, Webcom.Callback(snapshot => {
// this callback is called each time the data in your app at "the/targeted/path" is updated
console.info("data in my app is now:", snapShot.val());
}));
You can also send notifications to a webhook instead of a javascript callback (to do so, you must configure the
"myWebhook" webhook on the Webcom developer console):`javascript`
node.subscribe(Webcom.Event.ValueChange, Webcom.Webhook("myWebhook", "aContext"));
#### 5.c Write data into your data tree (ServerlessDb example)
`javascript`
node.set({foo: 'bar'})
.then(() => console.info("write operation succeeded"))
.catch(error => console.info("write operation failed:", error.message));
While the set method overwrites data, the merge one completes existing data:`javascript`
node.merge({baz: 42});`
The whole data tree of your application is nowjson`
{
"the": {
"targeted": {
"path": {
"foo": "bar",
"baz": 42
}
}
}
}
If you run a Node.js application, be careful to the network configuration: behind a company proxy, you just have to
set up usual environment variables https_proxy and http_proxy (or their uppercase counterparts):`shell script`
export http_proxy="http://my-proxy.my-company.com:8080"no_proxy` environment variable is also taken into account.
Note that the