Lambda to handle switchboard API requests
This repository contains multiple lambdas, altogether they handle switchboard API requests. They are bundled in the same RiffRaff artifact.
Located in src/switches.js
returns the list of switches.
Being an authenticated request if requires the following body mapping
{
"context" : {
"authorizer-principal-id" : "$context.authorizer.principalId"
}
}
Located in src/status.js
returns the status of all switches.
Being an authenticated request if requires the following body mapping
{
"context" : {
"authorizer-principal-id" : "$context.authorizer.principalId"
}
}
Located in src/toggle.js
sets the status of a switch to either on
or off
.
It's an authenticated request that requires two path parameters {switch}
and {status}
. {status}
can be only on
or off
. The body mapping is
## See http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
{
"params" : {
"path": {
#set($params = $input.params().get('path'))
"switch": "$util.escapeJavaScript($params.get('switch'))",
"status": "$util.escapeJavaScript($params.get('status'))"
}
},
"context" : {
"authorizer-principal-id" : "$context.authorizer.principalId",
"http-method" : "$context.httpMethod"
}
}
npm test
to run your tests once.nodemon --exec 'npm test' --ignore tmp
to watch your files and run tests on save.
static
contains the static UI that talks to switchboard lambda.
These steps can be done once
- Set up nginx mappings using dev-nginx.
npm install -g http-server
Run http-server static -p 3000
from the root of this project and go to switchboard.local.dev-gutools.co.uk