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

@deskree/postman-collection-generator

v1.1.2

Published

Package that generates Postman collection from controllers in Express.js

Downloads

27

Readme

postman-collection-generator

This package generates postman collection from express controllers.

Installing

Install package as a dev dependency via npm.

npm install --save @deskree/postman-collection-generator

Import package either into the base class of your controllers or to each controller individually:

import {PostmanControllerInterface} from "@deskree/postman-collection-generator";

Using

Controller Data Structure

postman-collection-generator creates postman collections from express controllers. In order for the collection and items to be generated correctly, each controller has to be a class that implements a PostmanControllerInterface and have the appropriate data structure. See example below:

// exampleController.ts
import {PostmanControllerInterface} from "@deskree/postman-collection-generator";

export class ExampleController implements PostmanControllerInterface {

    public name = 'Example Name of Postman Folder';
    public description = 'Example Description of Postman Folder';
    public routes = [
        {
            name: 'GET Something by id',
            url: '/example/{{id}}',
            method: 'GET',
            description: 'Get something from somewhere by some id',
            params: ['some_param=123'],
            headers: [{ key: 'Content-Type', value: 'application/json' }]
        },
        {
            name: 'Create Product',
            url: '/product',
            method: 'POST',
            body: {
                product: {
                    title: "Product Name",
                    price: 12,
                    tags: [
                        "Product"
                    ]
                }
            }
        }
    ]

    ...

Overall Data Structure

| Parameter | Type | Required | Description | |-------------|--------|----------|--------------------------------------------| | name | string | yes | Name of Postman folder (itemsGroup) | | description | string | no | Description of Postman folder (itemsGroup) | | routes | array | yes | List of Postman requests (items) |

routes Data Structure

| Parameter | Type | Required | Description | |-------------|------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------| | name | string | yes | Name of Postman request | | description | string | no | Description of Postman request | | url | string | yes | Postman request URL | | method | string | yes | Postman request method (ex. GET, POST, PUT, DELETE) | | params | array of strings | no | List of postman request parameters | | headers | array of objects | no | List of postman request headers. Each header must have the following structure: { key: 'Some header key', value: 'some header value' } | | body | object | no | Body of postman request |

Configure package.json

In order to run postman-collection-generator, just add the following line into your package.json's "scripts" with appropriate parameters. Example:

...
"scripts": {
    "postman": "postman-generator --folder src/controllers --outputDir ./ --integrationName Example --baseURL https://user.deskree.com/api/v1"
}
...

Command parameters:

| Parameter | Type | Required | Description | |-------------------|--------|----------|------------------------------------------------------| | --folder | string | yes | Folder with your controllers | | --outputDir | string | yes | Folder where you want to save the postman collection | | --integrationName | string | yes | Name of your postman collection | | --baseURL | string | yes | Base url for all requests within your collection |

Run

Once everything is set up and package.json is configured, just run the following command to generate your Postman collection:

npm run postman

Output

The command will generate collection.json file in the specified folder. You can import this collection into Postman.

Built with

Authors

License

This project is licensed under the MIT License