Package Exports
- machine-as-action
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (machine-as-action) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
machine-as-action
Build a modified version of a machine that proxies its inputs from request parameters, and proxies its exits through the response.
$ npm install machine-as-action --saveUsage
var asAction = require('machine-as-action');
var OpenWeather = require('machinepack-openweather');
// WeatherController.js
module.exports = {
getLatest: asAction(OpenWeather.getCurrentConditions),
somethingCustom: function (req, res) { /* ... */ },
// etc...
}Now you can run your machine using a HTTP or Socket.io request:
// For example, using jQuery and an out-of-the-box Sails.js route/blueprint configuration:
$.get('/weather/getLatest', {
city: 'San Francisco'
}, function (weatherData){
console.log(weatherData);
});Note that the machine definition you provide here doesn't have to come from an already-published machinepack-- it can be required locally from your project, or declared inline.
License
MIT © Mike McNeil