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 🙏

© 2026 – Pkg Stats / Ryan Hefner

generate-curl

v1.0.4

Published

將requests轉換成CURL用以debug的server tool

Readme

generate-curl

在後端收到requests時,常常需要將這些requests參數複製下來至postman或者insomnia重組,這十分的麻煩,generate-curl提供將requests轉換成curl的功能,讓後端人員可以使用此curl直接轉換至postman, insomnia, terminal來debug,另外,generate-curl也提供函數來讓重要資訊隱藏。

安裝

npm install generate-curl

如何使用

對於express.js server

express.js可直接使用

const express = require('express')
const bodyParser = require('body-parser')
const curl = require('generate-curl').curl()
const { utils: curlUtils } = require('generate-curl')

const app = express();

const upload = require('multer')()
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

app.use('/monitor', upload.none(), function(req, res) {
  const option = {
    headers: {
      '$["authorization"]': curlUtils.hide()
    }
  }
  console.log(curl(req, option))
  // curl -d '{"data":"12345"}' -H "host: localhost:3003" -H "content-type: application/json" -H "authorization: hide" -X POST 'http://localhost:3003/monitor?query=abc'
  res.send('ok')
})

app.listen(3003, function () {
  console.log('3003');
})

對於其他node.js server

只需在初始化generate-curl時設置不同框架的req所對應至express的參數即可

const curl = require('generate-curl').curl(req => {
  protocol: req.protocol,
  path: req.path,
  headers: req.headers,
  method: req.method,
  body: req.body,
  query: req.query,
  get (host) {
    return req.get(host)
  }
})

目前支援content-type

  • [x] application/json
  • [x] application/x-www-form-urlencoded
  • [x] multipart/form-data //對req.file不支援

提供的utils function

當有敏感資訊不想顯示出來時,可以使用option對此做調整,例如authorization不想顯示時,可使用hide隱藏,目前有以下特性:

  • 使用jsonPath來對應路徑,可以使用jsonPath的語法來對應複雜的巢狀json
  • utils.hide(): 隱藏value
  • utils.hash(): 雜湊value
  • utils.slice(start, end): 切割字串
  • 可自訂處理function

例子

const option = {
  headers: {
    '$["authorization"]': curlUtils.hide(),// authorization會被隱藏,即 authorization: hide
    '$["userId"]': curlUtils.hash(),// userId會被hash,即 hashuserId: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
    '$["uuid"]': curlUtils.slice(0, 3)// uuid會被字串切割,即 uuid: 123
  }
  body: {
    '$..name': value => `${value}1234`// 在body裡的name會被自訂fucntion處理,此處即加上1234字串
  }
}
console.log(curl(req, option))