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

skelenode-swagger

v0.0.1

Published

A collection of common swagger utilities like responses and params

Downloads

2

Readme

Skelenode Swagger

This is a Skelenode component to provide common swagger utilities for standard responses and params. This can be used standalone with any swagger implementation.

Installation

npm install skelenode-swagger

Usage

var swr = require('skelenode-swagger/respond');

// send a standard response from an express or restify route handler
swr.respond({ msg: 'Hello World!' }, res);

The resulting response sent is always in the same form:

{
  success: true|false,
  code: 200|404|ect.,
  result: { ...whatever... }
}

Response Methods

success(result, res[, internalCode])

Sends a 200 response with result.

custom(message, res[, internalCode, errorCode])

By default, sends a 400 response with the given message. Pass an optional errorCode to override the default.

forbidden(res[, internalCode, message])

Sends a 403 response. Pass an optional message to override the default message.

socketNotAllowed(res[, internalCode])

Sends a 403 response saying that a socket request is not allowed.

xhrNotAllowed(res[, internalCode])

Sends a 403 response saying that an XHR request is not allowed.

notFound(res[, internalCode])

Sends a 404 response saying that the given resource was not found.

itemNotFound(name, res[, internalCode])

Sends a 404 response saying that the resource named name was not found.

loginRequired(res[, internalCode])

Sends a 401 response saying that a login is required.

loginInvalidated(res[, internalCode])

Sends a 401 response saying that a login was invalidated.

paramRequired(field, res[, internalCode, errorCode])

Sends a 400 response saying that a field is required.

paramInvalid(field, res[, internalCode])

Sends a 400 response saying that a field is invalid.

serverError(res[, internalCode, errorCode])

By default, sends a 500 response with the details of a server error. Pass an optional errorCode to override the default.

disabled(res[, internalCode])

Sends a 500 response saying that feature is disabled.

localhostNotSupported(res[, internalCode])

Sends a 500 response saying that localhost is not supported.

notImplemented(res[, internalCode])

Sends a 501 response saying that API hasn't been implemented yet.

Contributing

Open a pull request with plenty of well-written instructions on what you are submitting and why you are submitting it