Files
DefinitelyTyped/types/http-proxy/http-proxy-tests.ts
Muhammad Fawwaz Orabi 971abae225 Fix dtslint issues
2017-07-12 05:42:17 +03:00

27 lines
585 B
TypeScript

import * as http from "http";
import * as HttpProxy from "http-proxy";
const proxy = new HttpProxy({
changeOrigin: true
});
proxy.on("error", (err) => {
console.error("An error occured:", err);
});
/**
* Test type inference of event listener parameters:
*/
proxy.on("start", (req, res, target) => {
const headers = req.headers; // defined;
const status = res.statusCode; // defined;
const partial =
typeof target === "string"
? target.substr(0) // defined;
: target.protocol; // defined;
});
http.createServer((req, res) => {
proxy.web(req, res);
});