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 🙏

© 2024 – Pkg Stats / Ryan Hefner

generator-drachtio

v0.3.7

Published

Yeoman generator for drachtio

Downloads

11

Readme

generator-drachtio

A yeoman generator for drachtio apps

install yeoman if you have not already

$ npm install -g yo

install the drachtio generator

npm install -g generator-drachtio

create a fresh directory for your project and run it

$ mdkdir my-project && cd $_
$ yo drachtio

Details

With this generator, you get a basic drachtio app template, and (optionally) a working test suite. Of course, you get my opinionated choice of some packages as well:

  • pino (for logging)
  • config (for config file management)

and the generated app will be using ES6 syntax and requiring a fairly recent-ish version of Node.js

When you run the generator it will ask you three things:

  • which SIP request types you want to handle in your application?
  • do you intend to use the drachtio-fsmrf module for freeswitch integration?
  • would like a docker-based test suite created for you?

A word on testing

Everyone agrees we should write test cases, but sometimes they are quite the pain to build, especially when we are talking about SIP server types of applications.

After quite a bit of experimenting, I've settled on creating my test cases using docker and docker-compose. (Of course, this requires you have docker installed on your laptop, but if you don't should anyways for all its other goodness).

The test suite that gets scaffolded out for you (if you request it) creates a docker-compose file (found in ./test/docker-compose-testbed.yaml) that creates a docker network and then starts up a drachtio container as well as a sipp container.

I find sipp is a good way to have a simple test UAC or UAS client that can send SIP transactions to the drachtio server and application that are under test. Additionally, if you are using the drachtio-fsmrf package in your app, it will throw a freeswitch container into the docker network for you as well.

As per usual, you run the tests by:

$ npm test

Try it out!

You will see that test stubs have been provided for each of the SIP request methods that you indicated you want to handle in your app.

Of course, to start with they are pretty simple (incoming INVITEs are connected either to freeswitch or the sipp UAS; other incoming request types are responded to with a 480 response), but the beauty of it is that the test scaffolding is all in place and should be pretty easy to build on from there.

You can also run code coverage reports:

$ npm run coverage

and lint your code:

$ npm run jslint

Little help?

I'm by no means a yeoman expert, and this generator is lacking a few niceties (e.g. doesn't prompt for things like author, description, license, etc). If anyone would like to help improve it I would love PRs.