wt-cli

Webtask CLI - all you need is code

  • 所有者: auth0/wt-cli
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Webtask CLI: all you need is code

Command line tool for using webtasks to create microservices in seconds.

Setup

$ npm i -g wt-cli
$ wt init

Usage

Create a webtask

Write webtask code to the hello-world.js file:

module.exports = function (cb) {
  cb(null, 'Hello webtasks!');
}
wt create hello-world.js

and call it...

curl https://webtask.it.auth0.com/api/run/{yours}/hello-world

Create a webtask (from a public URL)

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

Create a webtask with a secret

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

This is a real mongodb URL (powered by mongolab), no guarantee that it will work :)

Create a webtask that integrates with express.js

wt create https://raw.githubusercontent.com/auth0/wt-cli/master/sample-webtasks/express.js \
          --name express \
          --dependency express \
          --dependency body-parser

Log streaming

wt logs

Cron a webtask (long running)

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

This cron will insert a document in a mongo collection every 10 minutes

Get cron history

wt cron history mongogron

Get all scheduled webtasks

wt cron ls

Auth0 CLI: extend Auth0 with custom code (BETA)

Auth0 hooks enable you to extend the Auth0 platform with custom code. Auth0 CLI allows you to manage Auth0 hooks for your Auth0 account.

Auth0 hooks are webtasks associated with specific extensibility points of the Auth0 platform that are invoked by Auth0 runtime to execute your custom logic.

Setup

Follow the instructions from the Account > Webtasks panel on the Auth0 management dashboard to install and configure wt-cli. The package now includes auth0 binary in addition to wt.

NOTE While Auth0 CLI is in BETA, the wt-cli tool must be installed from a branch of this repository instead of the public npm registry. Use npm i -g auth0/wt-cli#auth0 to install the tool. The rest of the instructions on the Auth0 management portal applies without changes.

Overview

Auth0 CLI allows you to create, list, enable/disable, edit, and remove Auth0 hooks associated with specific extensibility points within the Auth0 platform, as well as receive real-time logging information generated by custom code.

The list of supported extensibility points will be growing over time. Currently, the following extensibility points are supported:

client-credentials-exchange
password-exchange
pre-user-registration
post-user-registration

For each of the extensibility points, there can be several Auth0 hooks created. A hook can be enabled or disabled, but only up to one hook per extensibility point can be enabled at a time. Disabled hooks are useful for staging new functionality.

Synopsis

The script below assumes you are creating an Auth0 hook for the pre-user-registration extensibility point using profile name tj-default. You can use any of the extensibility points listed above and the actual profile name has been provided to you during wt-cli setup.

# Scaffold sample code of an Auth0 hook:
auth0 scaffold -t pre-user-registration > file.js

# Create a new, disabled Auth0 hook:
auth0 create -t pre-user-registration --name my-extension-1 -p tj-default file.js

# Edit code of the Auth0 hook:
auth0 edit my-extension-1

# Enable the newly created extensibility point (all other hooks associated
# with the same extensibility point will be disabled):
auth0 enable my-extension-1 -p tj-default

# List hooks for a specific extensibility point:
auth0 ls -t pre-user-registration -p tj-default

# List all Auth0 hooks on your account:
auth0 ls -p tj-default

# Access streaming, real-time logs of all of your hooks:
auth0 logs -p tj-default

# Disable a hook:
auth0 disable my-extension-1 -p tj-default

# Delete a hook:
auth0 rm my-extension-1 -p tj-default

Closing remarks

Working behind a proxy

wt-cli supports operating behind a proxy as of v6.1.0. The cli relies on the HTTP_PROXY (or http_proxy) environment variable to determine if proxy support needs to be enabled. The HTTP_PROXY environment variable must be set to a uri according to the following table:, Protocol, Proxy Agent for http requests, Proxy Agent for https requests, Example, :----------:, :-------------------------------:, :--------------------------------:, :--------:, http, http-proxy-agent, https-proxy-agent, http://proxy-server-over-tcp.com:3128, https, http-proxy-agent, https-proxy-agent, https://proxy-server-over-tls.com:3129, socks(v5), socks-proxy-agent, socks-proxy-agent, socks://username:password@some-socks-proxy.com:9050 (username & password are optional), socks5, socks-proxy-agent, socks-proxy-agent, socks5://username:password@some-socks-proxy.com:9050 (username & password are optional), socks4, socks-proxy-agent, socks-proxy-agent, socks4://some-socks-proxy.com:9050, pac, pac-proxy-agent, pac-proxy-agent, pac+http://www.example.com/proxy.pac

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

主要指標

概覽
名稱與所有者auth0/wt-cli
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2015-06-05 21:27:22
推送於2025-03-18 15:25:02
最后一次提交2025-03-18 11:25:01
發布數100
最新版本名稱v12.3.0 (發布於 )
第一版名稱v1.0.0 (發布於 )
用户参与
星數322
關注者數114
派生數72
提交數626
已啟用問題?
問題數128
打開的問題數32
拉請求數122
打開的拉請求數13
關閉的拉請求數21
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?