Socket
Socket
Sign inDemoInstall

ts-retrofit

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-retrofit - npm Package Compare versions

Comparing version 1.10.3 to 1.11.0

20

lib/baseService.js

@@ -141,4 +141,4 @@ "use strict";

const pathParams = meta[methodName].pathParams;
const isAbsoluteURL = /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(path);
let url = isAbsoluteURL ? path : [endpoint, basePath, path].join("");
const options = meta[methodName].options || {};
let url = this.makeURL(endpoint, basePath, path, options);
for (const pos in pathParams) {

@@ -151,2 +151,12 @@ if (pathParams[pos]) {

}
makeURL(endpoint, basePath, path, options) {
const isAbsoluteURL = /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(path);
if (isAbsoluteURL) {
return path;
}
if (options.ignoreBasePath) {
return [endpoint, path].join("");
}
return [endpoint, basePath, path].join("");
}
_resolveHttpMethod(methodName) {

@@ -315,2 +325,8 @@ const meta = this.__meta__;

__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String, String, Object]),
__metadata("design:returntype", String)
], BaseService.prototype, "makeURL", null);
__decorate([
exports.nonHTTPRequestMethod,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),

@@ -317,0 +333,0 @@ __metadata("design:returntype", String)

39

lib/decorators.js

@@ -20,4 +20,5 @@ "use strict";

* @param url
* @param options
*/
const registerMethod = (method, url) => {
const registerMethod = (method, url, options) => {
return (target, methodName, descriptor) => {

@@ -27,2 +28,3 @@ ensureMeta(target, methodName);

target.__meta__[methodName].path = url;
target.__meta__[methodName].options = options;
};

@@ -33,7 +35,8 @@ };

* @param url
* @param options
* @sample @GET("/users")
* @constructor
*/
exports.GET = (url) => {
return registerMethod("GET", url);
exports.GET = (url, options) => {
return registerMethod("GET", url, options);
};

@@ -43,7 +46,8 @@ /**

* @param url
* @param options
* @sample @POST("/users")
* @constructor
*/
exports.POST = (url) => {
return registerMethod("POST", url);
exports.POST = (url, options) => {
return registerMethod("POST", url, options);
};

@@ -53,7 +57,8 @@ /**

* @param url
* @param options
* @sample @PUT("/users/{userId}")
* @constructor
*/
exports.PUT = (url) => {
return registerMethod("PUT", url);
exports.PUT = (url, options) => {
return registerMethod("PUT", url, options);
};

@@ -63,7 +68,8 @@ /**

* @param url
* @param options
* @sample @PATCH("/users/{userId}")
* @constructor
*/
exports.PATCH = (url) => {
return registerMethod("PATCH", url);
exports.PATCH = (url, options) => {
return registerMethod("PATCH", url, options);
};

@@ -73,7 +79,8 @@ /**

* @param url
* @param options
* @sample @DELETE("/users/{userId}")
* @constructor
*/
exports.DELETE = (url) => {
return registerMethod("DELETE", url);
exports.DELETE = (url, options) => {
return registerMethod("DELETE", url, options);
};

@@ -83,7 +90,8 @@ /**

* @param url
* @param options
* @sample @HEAD("/users/{userId}")
* @constructor
*/
exports.HEAD = (url) => {
return registerMethod("HEAD", url);
exports.HEAD = (url, options) => {
return registerMethod("HEAD", url, options);
};

@@ -93,7 +101,8 @@ /**

* @param url
* @param options
* @sample @OPTIONS("/users/{userId}")
* @constructor
*/
exports.OPTIONS = (url) => {
return registerMethod("OPTIONS", url);
exports.OPTIONS = (url, options) => {
return registerMethod("OPTIONS", url, options);
};

@@ -100,0 +109,0 @@ /**

@@ -23,2 +23,3 @@ import { AxiosRequestConfig, AxiosResponse, AxiosInstance } from "axios";

private _resolveUrl;
private makeURL;
private _resolveHttpMethod;

@@ -25,0 +26,0 @@ private _resolveHeaders;

@@ -13,51 +13,61 @@ import { ResponseType as AxiosResponseType, AxiosTransformer, AxiosRequestConfig } from "axios";

}
export interface HttpMethodOptions {
ignoreBasePath?: boolean;
}
/**
* GET decorator.
* @param url
* @param options
* @sample @GET("/users")
* @constructor
*/
export declare const GET: (url: string) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
export declare const GET: (url: string, options?: HttpMethodOptions | undefined) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
/**
* POST decorator.
* @param url
* @param options
* @sample @POST("/users")
* @constructor
*/
export declare const POST: (url: string) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
export declare const POST: (url: string, options?: HttpMethodOptions | undefined) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
/**
* PUT decorator.
* @param url
* @param options
* @sample @PUT("/users/{userId}")
* @constructor
*/
export declare const PUT: (url: string) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
export declare const PUT: (url: string, options?: HttpMethodOptions | undefined) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
/**
* PATCH decorator.
* @param url
* @param options
* @sample @PATCH("/users/{userId}")
* @constructor
*/
export declare const PATCH: (url: string) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
export declare const PATCH: (url: string, options?: HttpMethodOptions | undefined) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
/**
* DELETE decorator.
* @param url
* @param options
* @sample @DELETE("/users/{userId}")
* @constructor
*/
export declare const DELETE: (url: string) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
export declare const DELETE: (url: string, options?: HttpMethodOptions | undefined) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
/**
* HEAD decorator.
* @param url
* @param options
* @sample @HEAD("/users/{userId}")
* @constructor
*/
export declare const HEAD: (url: string) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
export declare const HEAD: (url: string, options?: HttpMethodOptions | undefined) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
/**
* OPTIONS decorator.
* @param url
* @param options
* @sample @OPTIONS("/users/{userId}")
* @constructor
*/
export declare const OPTIONS: (url: string) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
export declare const OPTIONS: (url: string, options?: HttpMethodOptions | undefined) => (target: BaseService, methodName: string, descriptor: PropertyDescriptor) => void;
/**

@@ -64,0 +74,0 @@ * Set base path for API service.

{
"name": "ts-retrofit",
"version": "1.10.3",
"version": "1.11.0",
"description": "A declarative and axios based retrofit implementation for JavaScript and TypeScript.",

@@ -5,0 +5,0 @@ "repository": "https://github.com/nullcc/ts-retrofit",

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