Skip to content

GaryChangCN/cURL-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

parse-curl-js

An better cURL string parser

Based on curlconverter

Usage

const { CURLParser } = require('parse-curl-js')
// or es6
import { CURLParser } from 'parse-curl-js'


const cURLParser = new CURLParser(`curl 'http://127.0.0.1:8080' -X POST -H "content-type: application/json" -d '{"data": true}'`)

console.log(cURLParser.parse())

Result

type RequestBodyType = 'text/plain' | 'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data'

interface RequestBody {
    type: RequestBodyType
    data: any
}


interface ParsedCURL {
    /** url */
    url: string
    /** query */
    query: ParsedUrlQuery
    /** request method uppercase */
    method: string
    /** request header ...... includes cookies */
    headers: {
        [props: string]: string
    }
    /** request body ...... parsed */
    body: RequestBody
}

LICENSE

MIT

About

๐Ÿ˜€ cURL string parser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published