powerbi-router

WebJar for powerbi-router

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

powerbi-router
Last Version

Last Version

0.1.5
Release Date

Release Date

Type

Type

jar
Description

Description

powerbi-router
WebJar for powerbi-router
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/Microsoft/powerbi-router

Download powerbi-router

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/powerbi-router/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>powerbi-router</artifactId>
    <version>0.1.5</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/powerbi-router/
implementation 'org.webjars.npm:powerbi-router:0.1.5'
// https://jarcasting.com/artifacts/org.webjars.npm/powerbi-router/
implementation ("org.webjars.npm:powerbi-router:0.1.5")
'org.webjars.npm:powerbi-router:jar:0.1.5'
<dependency org="org.webjars.npm" name="powerbi-router" rev="0.1.5">
  <artifact name="powerbi-router" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='powerbi-router', version='0.1.5')
)
libraryDependencies += "org.webjars.npm" % "powerbi-router" % "0.1.5"
[org.webjars.npm/powerbi-router "0.1.5"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : es6-promise jar [3.2.1,4)
org.webjars.npm : route-recognizer jar [0.1.11,0.2)

Project Modules

There are no modules declared in this project.

powerbi-router

Build Status NPM Version NPM Total Downloads NPM Monthly Downloads GitHub tag

Router for Microsoft Power BI. Given an http method and url pattern call the matching handler with the request and response object. Syntax matches common libraries such as express and restify. This library uses Route-recognizer to handle pattern matching such as /root/path/:name where name will be passed as paramter to the handler.

Documentation:

https://microsoft.github.io/powerbi-router

Installation:

npm install --save powerbi-router

Usage:

import * as Wpmp from 'window-post-message-proxy';
import * as Router from 'powerbi-router';

const wpmp = new Wpmp.WindowPostMessageProxy();
const router = new Router.Router(wpmp);

/**
 * Demonstrate 'syncrhonous' API with request and response.
 */
router.get('/report/pages', (request, response) => {
  return app.getPages()
    .then(pages => {
      response.send(200, pages);
    });
});

/**
 * Demonstrate 'asynchronous' API with accepted command, and events
 */
router.put('/report/pages/active', (request, response) => {
  const page = request.body;

  return app.validatePage(page)
    .then(() => {
      app.setPage(request.body)
        .then(page => {
          hpm.post(`/report/${reportId}/events/pageChanged`, page);
        }, error => {
          hpm.post(`/report/${reportId}/events/error`, error);
        });

      response.send(202);
    }, errors => {
      response.send(400, errors);
    });
});

/**
 * Demonstrate using path parameters and query parameters
 */
router.put('/report/pages/:pageName/visuals?filter=true', (request, response) => {
  const pageName = request.params.pageName;
  const filter = request.queryParams.filter;

  return app.validatePage(pageName)
    .then(() => {
      return app.getVisuals(filter)
        .then(visuals => {
          response.send(200, visuals);
        }, error => {
          response.send(500, error);
        });
    }, errors => {
      response.send(400, errors);
    });
});

/**
 * Demonstrate using wildcard matching
 */
router.get('*notfound', (request, response) => {
  response.send(404, `Not Found. Url: ${request.params.notfound} was not found.`);
});
org.webjars.npm

Microsoft

Open source projects and samples from Microsoft

Versions

Version
0.1.5