ts-retrofit
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -134,3 +134,3 @@ "use strict"; | ||
* Set static HTTP headers for API endpoint. | ||
* @param {IHeaders} headers | ||
* @param {Headers} headers | ||
* @return {(target: any, methodName: string, descriptor: PropertyDescriptor) => void} | ||
@@ -176,3 +176,3 @@ * @constructor | ||
* Set static query for API endpoint. | ||
* @param {IQuery} query | ||
* @param {Query} query | ||
* @return {(target: any, methodName: string, descriptor: PropertyDescriptor) => void} | ||
@@ -179,0 +179,0 @@ * @constructor |
import { BaseService } from "./baseService"; | ||
interface IHeaders { | ||
interface Headers { | ||
[x: string]: string | number; | ||
} | ||
interface IQuery { | ||
interface Query { | ||
[x: string]: string | number | boolean; | ||
@@ -81,7 +81,7 @@ } | ||
* Set static HTTP headers for API endpoint. | ||
* @param {IHeaders} headers | ||
* @param {Headers} headers | ||
* @return {(target: any, methodName: string, descriptor: PropertyDescriptor) => void} | ||
* @constructor | ||
*/ | ||
export declare const Headers: (headers: IHeaders) => (target: any, methodName: string, descriptor: PropertyDescriptor) => void; | ||
export declare const Headers: (headers: Headers) => (target: any, methodName: string, descriptor: PropertyDescriptor) => void; | ||
/** | ||
@@ -104,7 +104,7 @@ * Set HTTP header as variable in API method. | ||
* Set static query for API endpoint. | ||
* @param {IQuery} query | ||
* @param {Query} query | ||
* @return {(target: any, methodName: string, descriptor: PropertyDescriptor) => void} | ||
* @constructor | ||
*/ | ||
export declare const Query: (query: IQuery) => (target: any, methodName: string, descriptor: PropertyDescriptor) => void; | ||
export declare const Query: (query: Query) => (target: any, methodName: string, descriptor: PropertyDescriptor) => void; | ||
/** | ||
@@ -158,3 +158,3 @@ * Set query map for API endpoint. | ||
export declare const Part: (paramName: string) => (target: any, methodName: string, paramIndex: number) => void; | ||
export interface IPartDescriptor { | ||
export interface PartDescriptor { | ||
value: any; | ||
@@ -161,0 +161,0 @@ filename?: string; |
{ | ||
"name": "ts-retrofit", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "A axios based retrofit implementation for TypeScript.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/nullcc/ts-retrofit", |
import { | ||
GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, BasePath, Header, Query, | ||
Headers, Path, QueryMap, Body, FormUrlEncoded, Field, FieldMap, Multipart, | ||
Part, IPartDescriptor, BaseService, Response, HeaderMap, | ||
Part, PartDescriptor, BaseService, Response, HeaderMap, | ||
} from "../src"; | ||
@@ -13,3 +13,3 @@ | ||
export interface IUser { | ||
export interface User { | ||
id?: number; | ||
@@ -21,3 +21,3 @@ name: string; | ||
export interface ISearchQuery { | ||
export interface SearchQuery { | ||
title?: string; | ||
@@ -28,3 +28,3 @@ author?: string; | ||
export interface IAuth { | ||
export interface Auth { | ||
username: string; | ||
@@ -48,9 +48,9 @@ password: string; | ||
@POST("/users") | ||
async createUser(@Header("X-Token") token: string, @Body user: IUser): Promise<Response> { return <Response> {} }; | ||
async createUser(@Header("X-Token") token: string, @Body user: User): Promise<Response> { return <Response> {} }; | ||
@PUT("/users/{userId}") | ||
async replaceUser(@Header("X-Token") token: string, @Path("userId") userId: number, @Body user: IUser): Promise<Response> { return <Response> {} }; | ||
async replaceUser(@Header("X-Token") token: string, @Path("userId") userId: number, @Body user: User): Promise<Response> { return <Response> {} }; | ||
@PATCH("/users/{userId}") | ||
async updateUser(@Header("X-Token") token: string, @Path("userId") userId: number, @Body user: Partial<IUser>): Promise<Response> { return <Response> {} }; | ||
async updateUser(@Header("X-Token") token: string, @Path("userId") userId: number, @Body user: Partial<User>): Promise<Response> { return <Response> {} }; | ||
@@ -70,3 +70,3 @@ @DELETE("/users/{userId}") | ||
@GET("/search") | ||
async search(@Header("X-Token") token: string, @QueryMap query: ISearchQuery): Promise<Response> { return <Response> {} }; | ||
async search(@Header("X-Token") token: string, @QueryMap query: SearchQuery): Promise<Response> { return <Response> {} }; | ||
} | ||
@@ -81,3 +81,3 @@ | ||
}) | ||
async auth(@Body body: IAuth): Promise<Response> { return <Response> {} }; | ||
async auth(@Body body: Auth): Promise<Response> { return <Response> {} }; | ||
} | ||
@@ -112,3 +112,3 @@ | ||
@Multipart | ||
async upload(@Part("bucket") bucket: IPartDescriptor, @Part("file") file: IPartDescriptor): Promise<Response> { return <Response> {} }; | ||
async upload(@Part("bucket") bucket: PartDescriptor, @Part("file") file: PartDescriptor): Promise<Response> { return <Response> {} }; | ||
} |
@@ -7,3 +7,3 @@ import * as http from "http"; | ||
TEST_SERVER_ENDPOINT, API_PREFIX, TOKEN, UserService, SearchService, | ||
PostService, AuthService, FileService, IUser, ISearchQuery, IAuth, IPost, | ||
PostService, AuthService, FileService, User, SearchQuery, Auth, IPost, | ||
TEST_SERVER_PORT, | ||
@@ -46,3 +46,3 @@ } from "./fixtures"; | ||
.build(UserService); | ||
const newUser: IUser = { | ||
const newUser: User = { | ||
name: "Jane", | ||
@@ -125,3 +125,3 @@ age: 18 | ||
.build(UserService); | ||
const newUser: IUser = { | ||
const newUser: User = { | ||
name: "Jane", | ||
@@ -138,3 +138,3 @@ age: 18 | ||
.build(AuthService); | ||
const auth: IAuth = { | ||
const auth: Auth = { | ||
username: "test", | ||
@@ -182,3 +182,3 @@ password: "123456", | ||
.build(SearchService); | ||
const query: ISearchQuery = { | ||
const query: SearchQuery = { | ||
title: "TypeScript", | ||
@@ -185,0 +185,0 @@ author: "John Doe", |
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
101579