curl-express
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

curl-express

convert request to curl cmd

Build Status code style: prettier npm contributions welcome License: MIT

Install

npm install curl-express

Usage

Make sure curl-express middleware is placed after body paser,multipart handling middlewares

const express = require('express');
const curlExpress = require('curl-express');
 
const app = express();
const port = 3000;
 
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
 
// curl-express middleware
// it is placed after body paser,multipart handling middlewares
app.use(curlExpress());
 
// user can define omitted header or body payload
// Example:
// => app.use(curlExpress({omittedKeys: ['authorization']}));
 
app.all('*', (req, res) => {
  const { curlcmd } = req;
  console.log(curlcmd);
  // => curl -X GET 'http://localhost:3000/' -H 'host: localhost:3000' -H 'connection: keep-alive' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36' -H 'sec-fetch-mode: navigate' -H 'sec-fetch-user: ?1' -H 'dnt: 1' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'sec-fetch-site: none' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: my,en-US;q=0.9,en;q=0.8' -H 'cookie: test=test' -H 'if-none-match: W/"c-Lve95gjOVATpfV8EL5X4nxwjKHE"'
  res.send(curlcmd);
});
 
app.listen(port, () => console.log(`Example app listening on port ${port}!`));

Development

Docker Build

docker-compose build

Docker Run

docker-compose run curl-express

Install Dependencies

npm i

Run Test

npm t

License

MIT © Aung Myo Kyaw

Package Sidebar

Install

npm i curl-express

Weekly Downloads

74

Version

2.0.0

License

MIT

Unpacked Size

7.92 kB

Total Files

7

Last publish

Collaborators

  • aungmyokyaw