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

crosswalk

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crosswalk - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

CHANGELOG.md

8

dist/typed-request.d.ts
/** Type-safe wrapper around fetch() for REST APIs */
import { ExtractRouteParams, SafeKey, HTTPVerb, Unionize } from "./utils";
declare type ExtractRouteParamsVarArgs<T extends string> = {} extends ExtractRouteParams<T> ? [] : [params: ExtractRouteParams<T>];
import { ExtractRouteParams, SafeKey, HTTPVerb, Unionize, DeepReadonly } from "./utils";
declare type ExtractRouteParamsVarArgs<T extends string> = {} extends ExtractRouteParams<T> ? [] : [params: Readonly<ExtractRouteParams<T>>];
/** Utility for safely constructing API URLs */

@@ -14,3 +14,3 @@ export declare function apiUrlMaker<API>(prefix?: string): <Path extends keyof API>(endpoint: Path & string) => (...paramsList: ExtractRouteParamsVarArgs<Path & string>) => string;

export declare function typedApi<API>(options?: Options): {
request: <Path extends keyof API & string, Method extends (keyof API[Path] & "get") | (keyof API[Path] & "post") | (keyof API[Path] & "put") | (keyof API[Path] & "delete") | (keyof API[Path] & "patch")>(endpoint: Path, method: Method) => (queryParams: ExtractRouteParams<Path & string>, body: SafeKey<API[Path][Method], "request">) => Promise<SafeKey<API[Path][Method], "response">>;
request: <Path extends keyof API & string, Method extends (keyof API[Path] & "get") | (keyof API[Path] & "post") | (keyof API[Path] & "put") | (keyof API[Path] & "delete") | (keyof API[Path] & "patch")>(endpoint: Path, method: Method) => (queryParams: ExtractRouteParams<Path & string>, body: DeepReadonly<SafeKey<API[Path][Method], "request">>) => Promise<SafeKey<API[Path][Method], "response">>;
get: <Path_1 extends Extract<Unionize<API>, {

@@ -25,4 +25,4 @@ v: {

};
}>["k"] & keyof API & string>(endpoint: Path_2) => (params: ExtractRouteParams<Path_2 & string>, body: SafeKey<SafeKey<API[Path_2], "post">, "request">) => Promise<SafeKey<SafeKey<API[Path_2], "post">, "response">>;
}>["k"] & keyof API & string>(endpoint: Path_2) => (params: ExtractRouteParams<Path_2 & string>, body: DeepReadonly<SafeKey<SafeKey<API[Path_2], "post">, "request">>) => Promise<SafeKey<SafeKey<API[Path_2], "post">, "response">>;
};
export {};

@@ -16,1 +16,6 @@ /** Like T[K], but doesn't require K be assignable to keyof T */

}[keyof T];
export declare type Primitive = string | number | boolean | bigint | symbol | undefined | null;
/** Based on ts-essentials, but reduced to only JSON-compatible types */
export declare type DeepReadonly<T> = T extends Primitive ? T : T extends {} ? {
readonly [K in keyof T]: DeepReadonly<T[K]>;
} : Readonly<T>;
{
"name": "crosswalk",
"version": "1.0.3",
"version": "1.1.0",
"description": "Type-safe express routing with TypeScript",

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

@@ -146,4 +146,6 @@ # Crosswalk: safe routes for Express and TypeScript

$ http POST :/user
example here
$ http POST :/user name="Fred"
{
error: `data should have required property 'age'`,
}

@@ -150,0 +152,0 @@ You now have two representations of your API: `api.ts` and `api.schema.json`.

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