New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

http4js

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http4js - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

dist/main/core/Filters.d.ts

46

dist/main/core/HttpMessage.d.ts

@@ -16,47 +16,1 @@ import { Body } from "./Body";

export declare type HttpHandler = (Request) => Promise<Response>;
export declare type Filter = (HttpHandler: HttpHandler) => HttpHandler;
export declare enum Headers {
ACCEPT = "Accept",
ACCEPT_ENCODING = "Accept-Encoding",
ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method",
ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers",
AUTHORIZATION = "Authorization",
CACHE_CONTROL = "Cache-Control",
COOKIE = "Cookie",
CONTENT_LENGTH = "Content-Length",
CONTENT_TYPE = "Content-Type",
FORWARDED = "Forwarded",
HOST = "Host",
REFERER = "Referer",
USER_AGENT = "User-Agent",
X_FORWARDED_FOR = "X-Forwarded-For",
X_FORWARDED_Host = "X-Forwarded-Host",
X_CSRF_TOKEN = "X-Csrf-Token",
ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin",
ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials",
ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers",
ACCESS_CONTROL_MAX_AGE = "Access-Control-Max-Age",
ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods",
ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers",
ETAG = "ETag",
EXPIRES = "Expires",
LAST_MODIFIED = "Last-Modified",
LOCATION = "Location",
SERVER = "Server",
SET_COOKIE = "Set-Cookie",
TRANSFER_ENCODING = "Transfer-Encoding",
VARY = "Vary",
WWW_AUTHENTICATE = "WWW-Authenticate",
}
export declare enum HeaderValues {
APPLICATION_JSON = "application/json",
}
export declare enum Method {
GET = "GET",
POST = "POST",
PUT = "PUT",
PATCH = "PATCH",
DELETE = "DELETE",
OPTIONS = "OPTIONS",
HEAD = "HEAD",
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Headers;
(function (Headers) {
//Request headers
Headers["ACCEPT"] = "Accept";
Headers["ACCEPT_ENCODING"] = "Accept-Encoding";
Headers["ACCESS_CONTROL_REQUEST_METHOD"] = "Access-Control-Request-Method";
Headers["ACCESS_CONTROL_REQUEST_HEADERS"] = "Access-Control-Request-Headers";
Headers["AUTHORIZATION"] = "Authorization";
Headers["CACHE_CONTROL"] = "Cache-Control";
Headers["COOKIE"] = "Cookie";
Headers["CONTENT_LENGTH"] = "Content-Length";
Headers["CONTENT_TYPE"] = "Content-Type";
Headers["FORWARDED"] = "Forwarded";
Headers["HOST"] = "Host";
Headers["REFERER"] = "Referer";
Headers["USER_AGENT"] = "User-Agent";
Headers["X_FORWARDED_FOR"] = "X-Forwarded-For";
Headers["X_FORWARDED_Host"] = "X-Forwarded-Host";
Headers["X_CSRF_TOKEN"] = "X-Csrf-Token";
//Response headers
Headers["ACCESS_CONTROL_ALLOW_ORIGIN"] = "Access-Control-Allow-Origin";
Headers["ACCESS_CONTROL_ALLOW_CREDENTIALS"] = "Access-Control-Allow-Credentials";
Headers["ACCESS_CONTROL_EXPOSE_HEADERS"] = "Access-Control-Expose-Headers";
Headers["ACCESS_CONTROL_MAX_AGE"] = "Access-Control-Max-Age";
Headers["ACCESS_CONTROL_ALLOW_METHODS"] = "Access-Control-Allow-Methods";
Headers["ACCESS_CONTROL_ALLOW_HEADERS"] = "Access-Control-Allow-Headers";
Headers["ETAG"] = "ETag";
Headers["EXPIRES"] = "Expires";
Headers["LAST_MODIFIED"] = "Last-Modified";
Headers["LOCATION"] = "Location";
Headers["SERVER"] = "Server";
Headers["SET_COOKIE"] = "Set-Cookie";
Headers["TRANSFER_ENCODING"] = "Transfer-Encoding";
Headers["VARY"] = "Vary";
Headers["WWW_AUTHENTICATE"] = "WWW-Authenticate";
})(Headers = exports.Headers || (exports.Headers = {}));
var HeaderValues;
(function (HeaderValues) {
HeaderValues["APPLICATION_JSON"] = "application/json";
})(HeaderValues = exports.HeaderValues || (exports.HeaderValues = {}));
var Method;
(function (Method) {
Method["GET"] = "GET";
Method["POST"] = "POST";
Method["PUT"] = "PUT";
Method["PATCH"] = "PATCH";
Method["DELETE"] = "DELETE";
Method["OPTIONS"] = "OPTIONS";
Method["HEAD"] = "HEAD";
})(Method = exports.Method || (exports.Method = {}));

1

dist/main/core/Request.d.ts

@@ -23,1 +23,2 @@ import { Body } from "./Body";

}
export declare function request(method: string, uri: Uri | string, body?: Body | string, headers?: any): Request;

@@ -94,1 +94,7 @@ "use strict";

exports.Request = Request;
function request(method, uri, body, headers) {
if (body === void 0) { body = new Body_1.Body(new Buffer("")); }
if (headers === void 0) { headers = null; }
return new Request(method, uri, body, headers);
}
exports.request = request;

@@ -19,1 +19,2 @@ import { HttpMessage } from "./HttpMessage";

}
export declare function response(status?: number, body?: Body | string): Response;

@@ -56,1 +56,7 @@ "use strict";

exports.Response = Response;
function response(status, body) {
if (status === void 0) { status = 200; }
if (body === void 0) { body = new Body_1.Body(""); }
return new Response(status, body);
}
exports.response = response;
import { Response } from "./Response";
import { HttpHandler, Filter } from "./HttpMessage";
import { HttpHandler } from "./HttpMessage";
import { Request } from "./Request";
import { Http4jsServer } from "./Server";
import { Filter } from "./Filters";
export interface RoutingHttpHandler {

@@ -10,5 +11,2 @@ withFilter(filter: (HttpHandler) => HttpHandler): RoutingHttpHandler;

}
export declare function routes(path: string, method: string, handler: HttpHandler): ResourceRoutingHttpHandler;
export declare function getTo(path: string, handler: HttpHandler): ResourceRoutingHttpHandler;
export declare function postTo(path: string, handler: HttpHandler): ResourceRoutingHttpHandler;
export declare class ResourceRoutingHttpHandler implements RoutingHttpHandler {

@@ -28,1 +26,7 @@ server: Http4jsServer;

}
export declare function routes(method: string, path: string, handler: HttpHandler): ResourceRoutingHttpHandler;
export declare function getTo(path: string, handler: HttpHandler): ResourceRoutingHttpHandler;
export declare function postTo(path: string, handler: HttpHandler): ResourceRoutingHttpHandler;
export declare function putTo(path: string, handler: HttpHandler): ResourceRoutingHttpHandler;
export declare function patchTo(path: string, handler: HttpHandler): ResourceRoutingHttpHandler;
export declare function deleteTo(path: string, handler: HttpHandler): ResourceRoutingHttpHandler;

@@ -8,14 +8,2 @@ "use strict";

var Uri_1 = require("./Uri");
function routes(path, method, handler) {
return new ResourceRoutingHttpHandler(path, method, handler);
}
exports.routes = routes;
function getTo(path, handler) {
return new ResourceRoutingHttpHandler(path, "GET", handler);
}
exports.getTo = getTo;
function postTo(path, handler) {
return new ResourceRoutingHttpHandler(path, "POST", handler);
}
exports.postTo = postTo;
var ResourceRoutingHttpHandler = (function () {

@@ -98,1 +86,25 @@ function ResourceRoutingHttpHandler(path, method, handler) {

exports.ResourceRoutingHttpHandler = ResourceRoutingHttpHandler;
function routes(method, path, handler) {
return new ResourceRoutingHttpHandler(path, method, handler);
}
exports.routes = routes;
function getTo(path, handler) {
return new ResourceRoutingHttpHandler(path, "GET", handler);
}
exports.getTo = getTo;
function postTo(path, handler) {
return new ResourceRoutingHttpHandler(path, "POST", handler);
}
exports.postTo = postTo;
function putTo(path, handler) {
return new ResourceRoutingHttpHandler(path, "PUT", handler);
}
exports.putTo = putTo;
function patchTo(path, handler) {
return new ResourceRoutingHttpHandler(path, "PATCH", handler);
}
exports.patchTo = patchTo;
function deleteTo(path, handler) {
return new ResourceRoutingHttpHandler(path, "DELETE", handler);
}
exports.deleteTo = deleteTo;

@@ -19,4 +19,5 @@ export declare class Uri {

withQuery(name: string, value: string): Uri;
withProtocol(protocol: string): Uri;
private uriTemplateToExactPathParamCapturingRegex();
private uriTemplateToPathParamCapturingRegex();
}

@@ -50,2 +50,6 @@ "use strict";

};
Uri.prototype.withProtocol = function (protocol) {
this.protocol = protocol;
return this;
};
Uri.prototype.uriTemplateToExactPathParamCapturingRegex = function () {

@@ -52,0 +56,0 @@ return new RegExp(("^" + this.template + "$").replace(pathParamMatchingRegex, pathParamCaptureTemplate));

@@ -26,3 +26,3 @@ # http4js

//server is just a route with a handler
routes("/", "GET", handler)
routes("GET", "/", handler)
//.asServer(3000) //if we want to run on a port

@@ -42,3 +42,3 @@ //.start()

routes("/", "GET", (req: Request) => {
routes("GET", "/", (req: Request) => {
return new Promise(resolve => {

@@ -45,0 +45,0 @@ resolve(new Response(200))

@@ -15,3 +15,3 @@ ### Table of Contents

```typescript
routes("/path", "GET", (req: Request) => {
routes("GET", "/path", (req: Request) => {
return new Promise(resolve => {

@@ -18,0 +18,0 @@ resolve(new Response(200))

{
"name": "http4js",
"version": "1.1.3",
"version": "1.2.0",
"description": "A lightweight HTTP toolkit",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -38,6 +38,6 @@ ## http4js

- document withFilter for eg to add user on req or upgrade http to https
- add more in built filters :timing debug filter
- document a proxy
- document unit testing routing and fakes
- support express backend
- support express, koa backends

@@ -72,3 +72,3 @@ #### Example

routes("/path", "GET", handler)
routes("GET", "/path", handler)
.withHandler("/tom", "GET", handler)

@@ -75,0 +75,0 @@ .withRoutes(moreRoutes)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc