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.0.1 to 1.0.2

5

dist/main/core/RoutingHttpHandler.d.ts

@@ -12,6 +12,7 @@ import { Response } from "./Response";

export declare function postTo(path: string, handler: HttpHandler): ResourceRoutingHttpHandler;
export interface Filter {
}
export declare class ResourceRoutingHttpHandler implements RoutingHttpHandler {
server: Http4jsServer;
private path;
private handler;
private handlers;

@@ -21,3 +22,3 @@ private filters;

withRoutes(routes: ResourceRoutingHttpHandler): ResourceRoutingHttpHandler;
withFilter(filter: (HttpHandler) => HttpHandler): ResourceRoutingHttpHandler;
withFilter(filter: Filter): ResourceRoutingHttpHandler;
withHandler(path: string, method: string, handler: HttpHandler): ResourceRoutingHttpHandler;

@@ -24,0 +25,0 @@ asServer(port: number): Http4jsServer;

2

dist/main/core/Uri.d.ts

@@ -12,4 +12,2 @@ export declare class Uri {

matches: object;
private pathParamMatchingRegex;
private pathParamCaptureTemplate;
constructor(template: string);

@@ -16,0 +14,0 @@ static of(uri: string): Uri;

@@ -20,3 +20,5 @@ import {Request} from "./src/main/core/Request";

let moreRoutes = routes("/bob/{id}", "POST", (req) => { return new Response(201, new Body("created a " + req.path))});
let moreRoutes = routes("/bob/{id}", "POST", (req) => {
return new Response(201, new Body("created a " + req.path))
});

@@ -48,3 +50,10 @@ routes("/path", "GET", handler)

export * from "./src/main/core/RoutingHttpHandler";
export * from "./src/main/core/Request";
export * from "./src/main/core/Response";
export * from "./src/main/core/Server";
export * from "./src/main/core/Client";
export * from "./src/main/core/Body";
export * from "./src/main/core/Uri";
{
"name": "http4js",
"version": "1.0.1",
"version": "1.0.2",
"description": "",

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

@@ -27,6 +27,7 @@ ## Http4js

- code:
- daves advice
- extract form data
- ordering of filters
- other client verbs
- import lib to a new project as example
- write docs
- publish as library to npm

@@ -7,2 +7,3 @@ import {Response} from "./Response";

import {Uri} from "./Uri";
import {Filter} from "../../../dist/main/core/RoutingHttpHandler";

@@ -31,3 +32,2 @@ export interface RoutingHttpHandler {

private path: string;
private handler: object;
private handlers: object = {};

@@ -40,5 +40,3 @@ private filters: Array<any> = [];

this.path = path;
let verbToHandler = {verb: method, handler: handler};
this.handler = verbToHandler;
this.handlers[path] = verbToHandler;
this.handlers[path] = {verb: method, handler: handler};
}

@@ -55,3 +53,3 @@

withFilter(filter: (HttpHandler) => HttpHandler): ResourceRoutingHttpHandler {
withFilter(filter: Filter): ResourceRoutingHttpHandler {
this.filters.push(filter);

@@ -58,0 +56,0 @@ return this;

let URI = require('url');
const pathParamMatchingRegex: RegExp = new RegExp(/\{(\w+)\}/g);
const pathParamCaptureTemplate: string = "([\\w\\s]+)";
export class Uri {

@@ -16,4 +19,2 @@ path: string;

matches: object = {};
private pathParamMatchingRegex: RegExp = new RegExp(/\{(\w+)\}/g);
private pathParamCaptureTemplate: string = "([\\w\\s]+)";

@@ -45,3 +46,3 @@ constructor(template: string) {

let decodedUri = decodeURI(uri);
let pathParamNames = this.template.match(this.pathParamMatchingRegex)
let pathParamNames = this.template.match(pathParamMatchingRegex)
.map(it => it.replace("{", "").replace("}", ""));

@@ -60,7 +61,5 @@ let pathParams = this.uriTemplateToPathParamCapturingRegex().exec(decodedUri);

withQuery(name: string, value: string): Uri {
if (this.query && this.query.length > 0){
return Uri.of(this.href + `&${name}=${value}`)
} else {
return Uri.of(this.href + `?${name}=${value}`)
}
return this.query && this.query.length > 0
? Uri.of(this.href + `&${name}=${value}`)
: Uri.of(this.href + `?${name}=${value}`);
}

@@ -70,6 +69,6 @@

return new RegExp(this.template.replace(
this.pathParamMatchingRegex,
this.pathParamCaptureTemplate)
pathParamMatchingRegex,
pathParamCaptureTemplate)
);
}
}
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