A lightweight router for the Power BI JavaScript SDK which allows a hosting application to register routes to extend and integrate with Power BI embedded components.
Перейти к файлу
Or Shemesh 40c6f750a9
Merge pull request #4 from microsoft/readme_support_links
Update README.md with correct support links
2024-10-14 16:47:59 +03:00
.pipelines Merged PR 115344: [Static Analysis Fix]: Code sign error fix in official build 2020-09-23 10:58:09 +00:00
.vscode Add typescript and typings as devDependencies and use npm scripts for install, build, and test related actions to prevent need for global dependencies 2016-08-05 13:46:48 -07:00
src Setup tslint on build and test to enforce good practices and consistent style. 2016-08-22 10:22:50 -07:00
test Setup tslint on build and test to enforce good practices and consistent style. 2016-08-22 10:22:50 -07:00
.gitignore Merged PR 115305: Upgraded Gulp to v4 to fix build on Node v12 2020-09-23 08:02:49 +00:00
.travis.yml Update api_key in .travis.yml 2016-08-29 10:17:40 -07:00
CONTRIBUTING.md Add typescript and typings as devDependencies and use npm scripts for install, build, and test related actions to prevent need for global dependencies 2016-08-05 13:46:48 -07:00
LICENSE Initial Commit. Setup powerbi-router project with build and tests 2016-06-23 13:12:39 -07:00
README.md Update README.md with correct support links 2024-10-14 15:12:52 +03:00
SECURITY.md Merged PR 144024: Added SECURITY.md 2021-02-03 09:02:46 +00:00
gulpfile.js Merged PR 115305: Upgraded Gulp to v4 to fix build on Node v12 2020-09-23 08:02:49 +00:00
karma.conf.js Auto-format all files to use consistent tab size of 2. 2016-08-22 10:23:25 -07:00
package.json Merged PR 115305: Upgraded Gulp to v4 to fix build on Node v12 2020-09-23 08:02:49 +00:00
tsconfig.json Auto-format all files to use consistent tab size of 2. 2016-08-22 10:23:25 -07:00
tslint.json Setup tslint on build and test to enforce good practices and consistent style. 2016-08-22 10:22:50 -07:00
typings.json Add route-recognizer and restructure tests. 2016-06-23 13:12:39 -07:00
webpack.config.js Change webpack.config to enforce using package name as library name 2016-06-28 14:51:13 -07:00
webpack.test.config.js Rename tsconfig and webpack configs related to testing to be consistent with type of test and other projects. Add task to generate custom dts with no exports 2016-06-23 13:12:39 -07:00
webpack.test.tsconfig.json Auto-format all files to use consistent tab size of 2. 2016-08-22 10:23:25 -07:00

README.md

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.`);
});

Support

  • Feature Requests: Submit your ideas and suggestions to the Fabric Ideas Portal, where you can also vote on ideas from other developers.
  • Bug Reports and Technical Assistance: Visit the Fabric Developer Community Forum. Our team and community experts are ready to assist you.
  • Additional Support: Contact your account manager or reach out to the Fabric Support Team.