2.0.122 • Published 3 years ago

@tix-factory/http v2.0.122

Weekly downloads
11
License
MIT
Repository
github
Last release
3 years ago

@tix-factory/http

TODO

Example

import http from "http";
import { HttpClient, HttpRequest, httpMethods } from "@tix-factory/http";
const httpClient = new HttpClient();

const httpRequest = new HttpRequest(httpMethods.get, new URL("https://www.roblox.com/users/profile?username=WebGL3D"));

httpClient.send(httpRequest).then(httpResponse => {
	let headers = httpResponse.headers.map(header => `${header.name}: ${header.value}`);
	console.log(`request finished (${httpResponse.statusCode} ${http.STATUS_CODES[httpResponse.statusCode]})\n\tResponse URL: ${httpResponse.url}\n\t${headers.join("\n\t")}\n\n`, httpResponse.body.toString());
}).catch(console.error);
import { HttpResponse, HttpServer } from "@tix-factory/http";
const httpServer = new HttpServer({
	errorHandler: err => {
		consolee.error("unexpected exception with request", err);
	}
}, httpRequest => {
	return new Promise((resolve, reject) => {
		if (httpRequest.url.pathname === "/favicon.ico") {
			const httpResponse = new HttpResponse(404);
			httpResponse.addHeader("Content-Type", "application/json");
			httpResponse.body = Buffer.from(JSON.stringify({}));

			resolve(httpResponse);
			return;
		}

		setTimeout(() => {
			const httpResponse = new HttpResponse(200);
			httpResponse.addHeader("Content-Type", "application/json");
			httpResponse.body = Buffer.from(JSON.stringify({}));

			resolve(httpResponse);
		}, 5 * 1000);
	});
});
2.0.122

3 years ago

2.0.120

3 years ago

2.0.118

3 years ago

2.0.116

3 years ago

2.0.108

3 years ago

2.0.114

3 years ago

2.0.111

3 years ago

2.0.110

3 years ago

2.0.105

3 years ago

2.0.103

3 years ago

2.0.101

3 years ago

2.0.100

3 years ago

2.0.98

3 years ago

2.0.96

3 years ago

2.0.94

3 years ago

2.0.92

3 years ago

2.0.90

3 years ago

2.0.88

3 years ago

2.0.86

3 years ago

2.0.84

3 years ago

2.0.82

3 years ago

2.0.80

3 years ago

2.0.78

3 years ago

2.0.76

3 years ago

2.0.74

3 years ago

2.0.73

3 years ago

2.0.70

3 years ago

2.0.68

3 years ago

2.0.66

3 years ago

2.0.64

3 years ago

2.0.62

3 years ago

2.0.60

3 years ago

2.0.57

3 years ago

2.0.55

3 years ago

2.0.53

3 years ago

2.0.51

3 years ago

2.0.49

3 years ago

2.0.46

3 years ago

2.0.44

3 years ago

2.0.37

3 years ago

2.0.42

3 years ago

2.0.40

3 years ago

2.0.35

3 years ago

2.0.33

3 years ago

2.0.31

3 years ago

2.0.26

3 years ago

2.0.24

3 years ago

2.0.21

3 years ago

2.0.29

3 years ago

2.0.16

3 years ago

2.0.11

3 years ago

2.0.7

3 years ago