Particle-Blast
Middleware to conveniently blast your Particle device with request details.
Usage
First, create a new instance and pass in device credentials
let ParticleBlast = ; let blast = 'device': your device id 'token': your user token;
Calling the .fire()
method of the instance will return an Express/Connect compatible middlware function.
let express = ;let app = ; // using the blast instance we created previouslyapp // ... continue configuring express app ...
#fire([deviceFunction], [parseFunction], [callback])
Returns middleware function.
Arguments:
deviceFunction
- String, name of registered Particle Function you wish to invoke.
parseFunction
- Function, takes the request object as an argument. Use this to get whatever data you need from the request object. This will return the string data your registered Particle Function may require.
callback
- Function, callback to execute after your device returns an error and/or data.
let { return reqip;}; // arguments as passed by Particle Cloudlet { iferr console; conosle;}; app;
A single blast instance can be reused to run multiple registered functions if multiple functions are registered to the same device.
app; app;