Express endpoint creator (simplified)
[scripting/actions/Express endpoint creator (simplified)]
USE io/http/server/Simplified endpoint listener
INSTEAD.
Sets up a route for Express to receive requests on. Routes are expected to follow a format as per Express documentation.
Receiving state
and params
inputs initializes the route. Once the route is inialized, incoming requests will be sent out on request
, and corresponding responses will be expected on response
, bearing the same tag.
Example:
{}@0 received via state
{ "cwd": "express", "method": "GET", "route": "/status" }@0 is received via
params
State with route information added is sent via
state
An arbitrary GET request comes in via
request
{"status": 200, "headers": {}, "body": "OK"}@1 is received via
response
The received response is sent to the client.
Links:
https://expressjs.com/en/guide/routing.html
Input ports
state:
any
Receives script state.
params:
Receives method and route to match incoming requests against. Also specifies which running Express server instance to use via 'app-id'. The parameter 'app-id' must match the ID of a previously started Express server.
response:
Receives the response for a corresponding request prepared by the logic that connects
request
toresponse
. Properties:'status' specifies HTTP status code
'headers' list HTTP response headers
'body' specifies the body of the response. Format potentially depends on middlewares.
Output ports
state:
any
Sends updated script state.
request:
Sends incoming requests matching the route and method received via
params
.
Last updated