@api-ts/io-ts-http
Advanced tools
Comparing version 0.2.0-beta.11 to 0.2.0-beta.12
import * as t from 'io-ts'; | ||
import { HttpResponse } from './httpResponse'; | ||
import { HttpRequestCodec } from './httpRequest'; | ||
export declare type Method = 'GET' | 'POST' | 'PUT' | 'DELETE'; | ||
export declare type HttpRoute = { | ||
export declare const Method: t.KeyofC<{ | ||
get: number; | ||
post: number; | ||
put: number; | ||
delete: number; | ||
}>; | ||
export declare type Method = t.TypeOf<typeof Method>; | ||
export declare type HttpRoute<M extends Method = Method> = { | ||
readonly path: string; | ||
readonly method: Method; | ||
readonly method: Uppercase<M>; | ||
readonly request: HttpRequestCodec<any>; | ||
@@ -19,8 +25,14 @@ readonly response: HttpResponse; | ||
export declare type ApiSpec = { | ||
[Key: string]: { | ||
[Req: string]: HttpRoute; | ||
[ApiAction: string]: { | ||
[M in Method]?: HttpRoute<M>; | ||
}; | ||
}; | ||
export declare const apiSpec: <Spec extends ApiSpec>(spec: Spec) => Spec; | ||
export declare const httpRoute: <Props extends HttpRoute>(spec: Props) => Props; | ||
declare type UnknownKeysToError<Spec extends ApiSpec> = { | ||
[ApiAction in keyof Spec]: { | ||
[M in keyof Spec[ApiAction]]: M extends Method ? Spec[ApiAction][M] : `Unsupported HTTP Method. Use "get" | "post" | "put" | "delete"`; | ||
}; | ||
}; | ||
export declare const apiSpec: <Spec extends ApiSpec>(spec: UnknownKeysToError<Spec>) => Spec; | ||
export declare const httpRoute: <Props extends HttpRoute<"get" | "post" | "put" | "delete">>(spec: Props) => Props; | ||
export {}; | ||
//# sourceMappingURL=httpRoute.d.ts.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.httpRoute = exports.apiSpec = void 0; | ||
exports.httpRoute = exports.apiSpec = exports.Method = void 0; | ||
const t = __importStar(require("io-ts")); | ||
exports.Method = t.keyof({ | ||
get: 1, | ||
post: 1, | ||
put: 1, | ||
delete: 1, | ||
}); | ||
const apiSpec = (spec) => spec; | ||
@@ -5,0 +35,0 @@ exports.apiSpec = apiSpec; |
{ | ||
"name": "@api-ts/io-ts-http", | ||
"version": "0.2.0-beta.11", | ||
"version": "0.2.0-beta.12", | ||
"description": "Types for (de)serializing HTTP requests from both the client and server side", | ||
@@ -5,0 +5,0 @@ "author": "Patrick McLaughlin <patrickmclaughlin@bitgo.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38415
361