Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

twilio-run

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twilio-run

CLI tool to run Twilio Functions locally for development

  • 2.0.0-beta.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-46.78%
Maintainers
1
Weekly downloads
 
Created
Source

twilio-run

CLI tool to locally develop and deploy to Twilio Serverless

npm (scoped) npm GitHub All Contributors Code of Conduct PRs Welcome Travis (.com)


📦 Installation

You can install the CLI tool via npm or another package manager. Ideally install it as a dev dependency instead of global:

# Install it as a dev dependency
$ npm install twilio-run --save-dev

# Afterwards you can use by using:
$ node_modules/.bin/twilio-run

$ npx twilio-run

# Or inside your package.json scripts section as "twilio-run"

📖 Usage

  CLI tool to run Twilio Functions locally for development

  Usage
    $ twilio-run [dir]

  Options
    --load-local-env, -f Includes the local environment variables
    --env, -e [/path/to/.env] Loads .env file, overrides local env variables
    --port, -p <port> Override default port of 3000
    --ngrok [subdomain] Uses ngrok to create an outfacing url
    --no-logs Turns request logging off
    --detailed-logs Turns on detailed request logging
    --live Always serve from the current functions (no caching)
    --inspect [host:port] Enables Node.js debugging protocol
    --inspect-brk [host:port] Enables Node.js debugging protocol, stops execution until debugger is attached

  Examples
    $ twilio-run
    # Serves all functions in current functions sub directory

    $ twilio-run demo
    # Serves all functions in demo/functions

    $ PORT=9000 twilio-run
    # Serves functions on port 9000

    $ twilio-run --port=4200
    # Serves functions on port 4200

    $ twilio-run --env
    # Loads environment variables from .env file

    $ twilio-run --ngrok
    # Exposes the Twilio functions via ngrok to share them

🔬 API

The module also exposes two functions that you can use outside of the CLI tool:

runDevServer(port: number, baseDir: string): Promise<Express.Application>

This allows you to trigger running an express server that will expose all functions and assets. Example:

const { runDevServer } = require('twilio-run');

runDevServer(9000)
  .then(app => {
    console.log(`Server is running on port ${app.get('port')})`);
  })
  .catch(err => {
    console.error('Something failed');
  });
handleToExpressRoute(handler: TwilioHandlerFunction): Express.RequestHandler

You can take the handler function of a Twilio Function file and expose it in an existing Express server. Example:

const express = require('express');
const bodyParser = require('body-parser');
const { handlerToExpressRoute } = require('twilio-run');

const { handler } = require('./path/to/function.js');

const app = express();
app.use(bodyParser.urlencoded({ extended: false }));

app.all(handlerToExpressRoute(handler));

app.listen(3000, () => console.log('Server running on port 3000'));

💞 Contributing

This project welcomes contributions from the community. Please see the CONTRIBUTING.md file for more details.

Code of Conduct

Please be aware that this project has a Code of Conduct. The tldr; is to just be excellent to each other ❤️

✨ Contributors

Thanks goes to these wonderful people (emoji key):

Dominik Kundel
Dominik Kundel

💻
dbbidclips
dbbidclips

💻 🐛
Shelby Hagman
Shelby Hagman

🐛 💻
JavaScript Joe
JavaScript Joe

🐛
Stefan Judis
Stefan Judis

🐛 💻

This project follows the all-contributors specification. Contributions of any kind welcome!

📜 License

MIT

Keywords

FAQs

Package last updated on 20 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc