npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

twilio_turn

v1.6.35

Published

Express web-server with API endpoint to get Twilio STUN/TURN with realtime token

Readme

TURN Twilio

Express REST API server for hosting the turn credential fetching SDK interaction server side part for a webrtc session

Features

  • securely fetches Twilio turn cred in realtime in backend
  • Environment variables
  • REST api for secure and unsecure ports
  • does not expose twilio cred
  • sh script to fast install and run the application if launching from a docker container

Quick start

npm i twilio_turn -g
twilio_turn

Output

Setup

Obtain the values from twilio dashboard twilio console

  1. Add sid and auth token variable values to .env file

    echo "export TWILIO_ACCOUNT_SID='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'" > .env.prod echo "export TWILIO_AUTH_TOKEN='your_auth_token'" >> .env.prod

  2. Add location for ssl certs for hosting the secure api server to .env file

    privateKey='ssl_certs/server.key' certificate='ssl_certs/server.crt'

  3. Add secure and non secure ports to .env file

    tokenport=3000 tokensecureport=3001

Note : After hosting the app on ec2 or similar cloud server , ensure the port for rest apis accessible / open on TCP

Sample .env.dev file

TWILIO_ACCOUNT_SID='xx'
TWILIO_AUTH_TOKEN='yy'
privateKey='/home/altanai/Documents/webrtcdev/twilio_turn/ssl_certs/server.key'
certificate='/home/altanai/Documents/webrtcdev/twilio_turn/ssl_certs/server.crt'
tokenport=3000
tokensecureport=3001

Manual Run

set the environment for dotenv files to pick up location of ssl certs for host the api servera nd twillio creds Manual Starting the application with environment varaible

NODE_ENV=dev node token.js

Check Env

console.log(process.env);

start the application

npm install
npm start

check its working by opening another tab and listening for port specified

netstat -anp | grep 3000

Test

Test the application

curl -X POST http://localhost:3000/token

or on secure protocol

 curl -X POST  https://localhost:3001/token

output format

{
"username": "xx",
"ice_servers": [
{
"url": "stun:global.stun.twilio.com:3478?transport=udp",
"urls": "stun:global.stun.twilio.com:3478?transport=udp"
},
{
"username": "xx",
"credential": "yy",
"url": "turn:global.turn.twilio.com:3478?transport=udp",
"urls": "turn:global.turn.twilio.com:3478?transport=udp"
},
{
"username": "xx",
"credential": "yy",
"url": "turn:global.turn.twilio.com:3478?transport=tcp",
"urls": "turn:global.turn.twilio.com:3478?transport=tcp"
},
{
"username": "xx",
"credential": "yy",
"url": "turn:global.turn.twilio.com:443?transport=tcp",
"urls": "turn:global.turn.twilio.com:443?transport=tcp"
}
],
"date_updated": "Fri, 01 May 2020 01:42:57 +0000",
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"ttl": "86400",
"date_created": "Fri, 01 May 2020 01:42:57 +0000",
"password": "yy"
}

Add the .env with creds to .gitignore to prevent them from leaking

echo "twilio.env" >> .gitignore

Check status

sudo netstat -tunlp

The options used in this command have the following meaning:

-t - Show TCP ports.
-u - Show UDP ports.
-n - Show numerical addresses instead of resolving hosts.
-l - Show only listening ports.
-p - Show the PID and name of the listener’s process. This information is shown only if you run the command as root or sudo user.

Debug and help

Issue 1 Curls fails for self signe dcert

curl -X POST https://localhost:3001/token

curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

solution add the -k or --insecure switch to disable SSL certificate verification.

Issue2 pm2 script stat error

[PM2][ERROR] Script not found:

solution

pm2 start npm --name twilio_turn twilio_turn