Webtask

Documentation

Getting Started

Run code in 30 seconds

For customized documentation and ready to run samples, please log in.

Setup

The recommended way of using webtask is through the wtcommand line interface.

Install the CLI

Once you set it up, here are some common examples of usage.

Create a webtask (from a local file)

Creates a webtask based on a local file and returns a URL that can be used to execute it.

$ echo "module.exports = function(cb) { cb(null, 'hello world'); }" > foo.js
$ wt create foo.js          

Specifying --watch modifier will watch for file changes and refresh the webtask

Create a webtask (from a public URL)

Creates a webtask that when called it will fetch the code from that public URL and execute it. By default the returned URL causes the webtask code to be read from storage every time the webtask is executed, which is useful when the code changes frequently during development. In order to improve performance once the code is stable, use the --prod modifier to generate a URL that caches the code across executions.

$ wt create https://raw.githubusercontent.com/auth0/wt-cli/master/sample-webtasks/html-response.js --name html-response-url          

Log streaming

Shows the log streaming of all your webtasks. All console.log calls will be available.

$ wt logs          

Create a webtask with a secret

Create a webtask that depends on a secret (a mongodb connection string).

$ wt create https://raw.githubusercontent.com/auth0/wt-cli/master/sample-webtasks/mongodb.js --name mongo --secret MONGO_URL=mongodb://webtask:supersecret@ds047592.mongolab.com:47592/webtask-examples

Secrets are encrypted with AES256-CBC. This is a real mongodb URL (powered by mongolab), no guarrantee that it will work :)

Cron a webtask

Cron a webtask that will run every 10 minutes.

$ wt cron schedule -n mongocron -s MONGO_URL=mongodb://webtask:supersecret@ds047592.mongolab.com:47592/webtask-examples 10m https://raw.githubusercontent.com/auth0/wt-cli/master/sample-webtasks/mongodb.js          

Create a webtask that uses express.js

You can use the express framework inside a webtask. Specify --no-parse and --no-merge modifiers to keep the request raw.

$ wt create express.js --no-parse --no-merge          

Get cron history

Get a history of all the runs of a specific cron.

$ wt cron history mongocron          

Get all crons

Get a list of all the crons you have registered.

$ wt cron ls   

More

Explore more at github.com/auth0/wt-cli