Giter Site home page Giter Site logo

aungmyokyaw / curl-express Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 19 KB

express middleware for intercepting request and copy as curl

Home Page: http://npm.im/curl-express

License: MIT License

JavaScript 9.88% TypeScript 88.95% Dockerfile 1.16%
curl-express express-request-to-curl curl express express-middleware

curl-express's Introduction

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

curl-express's People

Contributors

aungmyokyaw avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.