A generic messaging component to send HTTP style message payloads over the window.postMessage API. Requires an implementation of window postMessage proxy such as 'window-post-message-proxy'
Перейти к файлу
Wallace Breza 31917b68cc Added travis build status image 2016-06-30 08:02:03 -07:00
.vscode Update task runner and CONTRIBUTING.md config to use gulp build instead of tsc 2016-06-27 16:38:49 -07:00
src Update getTrackingProperties method to test for existence of headers object before attempting to access id property. 2016-06-29 15:27:57 -07:00
test Change addTrackingProperties to only set header.id if trackingProperties is defined and has id property. 2016-06-22 11:42:44 -07:00
.gitignore Initial Commit. Add HttpPostMessage class with build and test setup. 2016-05-13 13:14:46 -07:00
.travis.yml Add .travis.yml 2016-06-29 18:10:54 -07:00
CONTRIBUTING.md Update CONTRIBUTING.md to new github repo url 2016-06-27 16:38:52 -07:00
LICENSE Initial Commit. Add HttpPostMessage class with build and test setup. 2016-05-13 13:14:46 -07:00
README.md Added travis build status image 2016-06-30 08:02:03 -07:00
gulpfile.js Update header generation to use webpack Banner plugin 2016-06-29 15:08:42 -07:00
karma.conf.js Update karma config to use --chrome flag for testing with chrome instead of debug. Update related files (package.json and CONTRIBUTING.md) 2016-06-08 13:27:47 -07:00
package.json 0.1.2 2016-06-29 18:11:19 -07:00
tsconfig.json Change build to use webpack as umd library and add gulp task to generate custom dts without exports 2016-06-17 13:15:26 -07:00
typings.json Change build to use webpack as umd library and add gulp task to generate custom dts without exports 2016-06-17 13:15:26 -07:00
webpack.config.js Change web.config to enforce using package name as library name 2016-06-28 14:48:07 -07:00
webpack.test.config.js Change build to use webpack as umd library and add gulp task to generate custom dts without exports 2016-06-17 13:15:26 -07:00
webpack.test.tsconfig.json Change build to use webpack as umd library and add gulp task to generate custom dts without exports 2016-06-17 13:15:26 -07:00

README.md

htt-post-message

Build Status

A generic messaging component to send HTTP style message payloads over the window.postMessage API. Requires an implementation of window postMessage proxy such as 'window-post-message-proxy'.

Installation

npm install -g http-post-message

Usage

The HttpPostMessage takes in an object that implements the IPostMessage interface which is just one method postMessage which returns a Promise.

In the case below we created a mock postMessage proxy, but in normal usage you would likely use the accompanying library window-post-message-proxy.

import * as hpm from 'http-post-message';

const stubWindowPostMessageProxy: hpm.IPostMessage = {
  postMessage(message: any) {
    console.log(message);
    return Promise.resolve(message):
  }
}

const httpPostMessage = new hpm.HttpPostMessage(stubWindowPostMessageProxy);

httpPostMessage.get('target/path')
  .then(response => {
    ...
  });

Methods

The object supports all the standard http methods, get, post, put, patch, and delete. You can also send an IRequest object directly to the lower-level send method.