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

wrapman

v1.1.1

Published

Postman API request collection wrapper that generates an axios http client ๐ŸŽ

Downloads

18

Readme

wrapman ๐ŸŽ

Postman API request collection wrapper that generates an axios http client.

Usage

npm i wrapman

# Generate a flattened JSON file
npx wrapman -i path/to/postman-collection.json -d data

# Read the source collection from a URL
npx wrapman -i https://api.com/my/collection/json --url -d data

Import the flattened JSON file and initialize an API client.

import { WrapmanApiClient } from 'wrapman'
import wrapmanJson from 'data/wrapman.json'

const apiClient = new WrapmanApiClient({
  collection: wrapmanJson
})

// Wraps axios.request.
// https://axios-http.com/docs/res_schema
// https://axios-http.com/docs/handling_errors
const res = await apiClient.request('Pet Store Collection::Pet::Get Pet')

Programmatically

If the CLI doesn't work for you, generate the flattened collection yourself.

import { Wrapman } from 'wrapman'

const wrapman = new Wrapman({
  collectionPath: 'path/to/postman-collection.json'
})

const flattenedJson = await wrapman.flatten()

// Do something fancy with flattenedJson.

Request IDs

Given a postman collection like the Pet Store:

Pet Store Collection/
  Pet/
    Create Pet
    Get Pet
    Update Pet
    Get Pet After Update
    Delete Pet
    Get Pet After Delete

Wrapman will generate an API client with request IDs that mimic the collection folder hierarchy, joined by ::

await apiClient.request('Pet Store Collection::Pet::Create Pet', {
  data: {
    name: 'Fido',
    type: 'dog'
  }
})

await apiClient.request('Pet Store Collection::Pet::Get Pet', {
  vars: {
    pet_id: 123
  }
})

Variables and Prefix

Given a request ID Pet Store Collection::Pet::Get Pet and a request url {{url}}/pet/{{pet_id}}, you can simplify API client usage with base variable replacement and a prefix.

import { WrapmanApiClient } from 'wrapman'
import wrapmanJson from 'data/wrapman.json'

const apiClient = new WrapmanApiClient({
  collection: wrapmanJson,
  prefix: 'Pet Store Collection',
  vars: {
    url: 'https://petstore.swagger.io/v2'
  }
})

await apiClient.request('Pet::Get Pet', {
  vars: {
    pet_id: 123
  }
})

// GET https://petstore.swagger.io/v2/pet/123

Happy wrapping! ๐ŸŒฏ