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

ts-http-server

v1.0.10

Published

Ts-http is an HTTP middleware that is encapsulated by typescript. It implements HTTP request data using GET and POST at the back end of node, unifies input parameters, and returns a Promise value, which can be invoked conveniently by async+await combinati

Downloads

7

Readme

Ts-http is an HTTP middleware that is encapsulated by typescript. It implements HTTP request data using GET and POST at the back end of node, unifies input parameters, and returns a Promise value, which can be invoked conveniently by async+await combination of ES6. I hope you like ~

ts-http是使用typescript封装的http中间件,实现在node后端使用GET及POST进行http请求数据,统一了输入参数,并且返回一个Promise的值,可使用ES6的async+await组合方便的进行调用。希望您喜欢~

Install

npm install ts-http --save

Usage


import http from "ts-http";

Options


    let getOpt = {
        method: "GET",
        option: {
            hostname: "192.168.0.126",
            port: '8080',
            path: '/api/get',
            data: {
                err: 1
            },
            __timeout: 5
        }
    }

    let postOpt = {

        method: 'POST',
        option: {
            hostname: '192.168.0.126',
            port: '8080',
            path: '/api/post',
            data: {
                test: 100,
                err: 1
            },
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            __timeout: 5
        }
    }
    

Example


 console.log('A')
    let a = await http.request(getOpt);
    if (a.err!) {
        console.log('get出错:' + a.err)
        return;
    }
    console.log(a);
    console.log('B');
    let b = await http.request(postOpt);
    if (b.err!) {
        console.log('post出错:' + b.err)
        return;
    }
    console.log(b);

Result

-----------run-------------
A
{ data: '{"code":90000,"msg":"get错误返回","data":{"id":"1","name":"item"}}' }
B
{ data: '{"code":90000,"msg":"post错误返回","data":{"id":"2","name":"item"}}' }
此错误返回是因为带了参数err=1,所以证明运行是正确的。
-----------END run-------------

Other

生成的JS文件在dist目录中,可使用JS调用,调用方式雷同,不再重复。

The generated JS file can be called in the dist directory using the JS call, and the call is identical and no longer repeats.

Licences

[MIT]