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

apidoc-plugin-websocket

v1.1.3

Published

Only a simple websocket plugin for apidoc.

Downloads

10

Readme

apidoc-plugin-websocket

Only a simple websocket plugin for apidoc. you can make websocket request directly at document pages generated by apidoc and this plugin to test your interface.

apidoc search in global node modules dir and local node_modules for modules that start with apidoc-plugin-. (local installed plugins have higher priority)

Install

Make sure the old versions has been removed!

 npm uninstall apidoc-plugin-bic-ws

then install the current:

 npm install apidoc-plugin-websocket --save-dev

Run

After install this pulgin in right position, run apidoc in your apidoc.json directory like this:

apidoc -i example -t ./node_modules/apidoc-plugin-websocket/template

Arg example is your source directory path and the default apidoc/template must be replaced with apidoc-plugin-websocket/template because of incompatible.

Configuration

Enhance Tag

@api [{type}] cmd:func your_api_title

Permited value for type is:

  • get
  • post
  • websocket
  • get,websocket
  • post,websocket

New Tag

@apiWebsocket arg

Permited value for arg is:

  • boolean
  • {cmd:func} url
  • {cmd:func}
  • url

Example Use

In case websocket request only

Declare request type in @api tag and provide a server address using @apiWebsocket tag,

/**
 * @api {websocket} do:somthing for do somthing
 * @apiGroup User
 * @apiName doSomething
 * @apiWebsocket ws://localhost:8082
 */

Optional,you can turn on the websocket request for all interfaces by adding a single line to apidoc.json:

"wsRequest": "ws://localhost:8082"

after it we simplified the configuration:

/**
 * @api {websocket} do:somthing for do somthing
 * @apiGroup User
 * @apiName doSomething
 */

well, go a step further:

/**
 * @api do:somthing for do somthing
 * @apiGroup User
 * @apiName doSomething
 */

maybe there is a subpath in ws server address,we need @apiWebsocket again:

/**
 * @api do:somthing for do somthing
 * @apiGroup User
 * @apiName doSomething
 * @apiWebsocket /subpath
 */

That's all!combining wsRequest and subpath is the duty of the plugin

Case of websocket and http request both

Sometimes,we hava to support http and websocket interface meanwhile,there is only a little more thing to do it.for http interface,use @api as a native way,then add the websocket to {type} block such as:

/**
 * @api {get,websocket} user/look look a user
 * @apiGroup User
 * @apiName lookUser
 */

or if you want to custom websocket info, @apiWebsocket come again:

/**
 * @api {get,websocket} user/find find a user
 * @apiGroup User
 * @apiName findUser
 * @apiWebsocket {ws_user:ws_find}
 */

Global Settings

the wsRequest key-vlaue in apidoc.json file like this

"wsRequest": "ws://localhost:8082"

behaves just as the way as sampleUrl; it applied by plugin automatically unless you turn off at method level:

/**
 * @apiWebsocket false
 */

Note

  • this plugin work with the handlebars template,so have to run with -t opation.
  • all changes powered by apidoc worker and parser extension,see parser and worker directory for detail.