Skip to content

Instantly share code, notes, and snippets.

@masato
Last active December 27, 2015 18:01
Show Gist options
  • Save masato/0c8a2dc03a70258fe9cb to your computer and use it in GitHub Desktop.
Save masato/0c8a2dc03a70258fe9cb to your computer and use it in GitHub Desktop.
Webhook as a ServiceでIoTのserverlessなバックエンド考える - Part 2: Webtask.ioのHello world ref: http://qiita.com/masato/items/5689238a4d90cfd8a307
{
"default": {
"url": "https://webtask.it.auth0.com",
"container": "{アカウントのコンテナ名}",
"token": "{アカウントのwebtask token}"
}
}
$ sudo npm install wt-cli -g
$ wt init xxx@gmail.com
Please enter the verification code we sent to xxx@gmail.com below.
Verification code:
$ echo $RESTRICTED_TOKEN
eyJhxxx
$ curl -X POST \
"https://webtask.it.auth0.com/api/run/{アカウントのコンテナ名}?name=Masato&key=eyJhxxx"
"Hello, Masato"
Welcome to webtasks! Create your first one as follows:
$ echo "module.exports = function (cb) { cb(null, 'Hello'); }" > hello.js
$ wt create hello.js
Run your new webtask like so:
$ curl https://webtask.it.auth0.com/api/run/{アカウントのコンテナ名}/hello?webtask_no_cache=1
HTTPS POST /api/tokens/issue
Content-Type: application/json
export RESTRICTED_TOKEN=$(curl -s https://webtask.it.auth0.com/api/tokens/issue -H "Authorization: Bearer $RESTRICTED_TOKEN" -H "Content-Type: application/json" --data-binary '{"url":"http://bit.ly/18L4CmA"}')
return function (context, cb) {
cb(null, "Hello, " + context.data.name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment