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

inversify-express-doc

v1.4.6

Published

Smart documentation for an inversify express based API

Downloads

13

Readme

inversify-express-doc

Build Status

Smart API documentation for an inversify express based API

Why would i use this?

If you are reading this, I probably don't need to tell you how awesome inversify or express are, since you are most likely already using inversify-express if you landed on this page. If not, you should check it out.

Since inversify express allows you to declare your routes directly on your classes/functions with decorators, i thought it would be cool to just use these decorators to also generate documentation about these routes. In this way you dont need to make any changes to your code, and it will automatically generate api documentation(and expose it on a /doc endpoint if you want).

It just works™

If you are already using inversify-express-utils, all you need to do is pass the inversify container to inversify-express-doc. Now all your documentation is availlable!

example:

import { Container } from 'inversify';
import { load } from 'inversify-express-doc';

const container = new Container();
// load inversify bindings.. 
// start express server before loading inversify-express-doc
load(container);

Showing your documentation

There are two ways to use the documentation generated. The easiest is to simply import 'inversify-express-doc' in your inversify config file, like so: (it will then automatically bind the DocController to the kernel)

import 'inversify-express-doc';

You can go to /doc to view the automatically generated api documentation, you might want to redirect there from your base path. The standard documentation output looks like this:

img

Alternatively, get the raw json documentation and do with it what you want:

import { getDocumentationData } from 'inversify-express-doc';
const apiDocumentation = getDocumentationData();
// Do stuff!

Advanced

inversify-express-doc also exposes a @Doc decorator for your endpoints, which you can use to add details about it for your users.

Since there might be some additional information you want to gather about your endpoints, like what kind of authorization they require, you can wrap your middleware in an object that exposes some extra info. These objects require a name and a value field, in addition to a middleware field(which is what will be passed to inversify-express-utils like usual).

This name/value info will then be shown in the documentation.

Backwards compatibility

Instead of using the inversify metadata to generate the documentation by loading the inversify container, it is still also possible to replace the inversify-express-util decorators with the inversify-express-doc decorators. But this option will no longer be supported in future releases.