Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Layoric committed Oct 13, 2023
2 parents 88322ac + 67df913 commit 1a25375
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,9 +1031,9 @@ class JsonApiClient {
}
exports.JsonApiClient = JsonApiClient;
function getMethod(request, method) {
return (method !== null && method !== void 0 ? method : typeof request.getMethod == "function")
return method !== null && method !== void 0 ? method : (typeof request.getMethod == "function"
? request.getMethod()
: HttpMethods.Post;
: HttpMethods.Post);
}
exports.getMethod = getMethod;
function getResponseStatus(e) {
Expand Down
2 changes: 1 addition & 1 deletion dist/servicestack-client.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/servicestack-client.min.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/servicestack-client.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,9 @@ export class JsonApiClient {
}
}
export function getMethod(request, method) {
return (method ?? typeof request.getMethod == "function")
return method ?? (typeof request.getMethod == "function"
? request.getMethod()
: HttpMethods.Post;
: HttpMethods.Post);
}
export function getResponseStatus(e) {
return e.responseStatus ?? e.ResponseStatus ??
Expand Down
4 changes: 2 additions & 2 deletions dist/servicestack-client.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -1245,9 +1245,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
}());
exports.JsonApiClient = JsonApiClient;
function getMethod(request, method) {
return (method !== null && method !== void 0 ? method : typeof request.getMethod == "function")
return method !== null && method !== void 0 ? method : (typeof request.getMethod == "function"
? request.getMethod()
: HttpMethods.Post;
: HttpMethods.Post);
}
exports.getMethod = getMethod;
function getResponseStatus(e) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@servicestack/client",
"title": "ServiceStack Client Utils",
"version": "2.0.11",
"version": "2.0.12",
"description": "ServiceStack's TypeScript library providing convenience utilities in developing web apps. Integrates with ServiceStack's Server features including ServiceClient, Server Events, Error Handling and Validation",
"homepage": "https://github.com/ServiceStack/servicestack-client",
"license": "BSD-3-Clause",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1455,9 +1455,9 @@ export class JsonApiClient {
}

export function getMethod(request:any, method?:string) {
return method ?? typeof (request as any).getMethod == "function"
return method ?? (typeof(request as any).getMethod == "function"
? (request as any).getMethod()
: HttpMethods.Post
: HttpMethods.Post)
}

export function getResponseStatus(e:any) {
Expand Down
8 changes: 8 additions & 0 deletions tests/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
errorResponse,
errorResponseExcept,
toObject,
getMethod,
} from '../src/index';
import {humanify} from "../dist";
import { Hello } from "./dtos/test.dtos";

describe ('Util Tests', () => {
it ('Can parse cookie', done => {
Expand Down Expand Up @@ -119,4 +121,10 @@ describe ('Util Tests', () => {
expect(humanify('TheID2WithWord')).eq('The ID2 With Word')
expect(humanify('Leave me Alone!')).eq('Leave me Alone!')
})

it ('Resolves correct HTTP Method', () => {
expect(getMethod(new Hello())).eq('POST')
expect(getMethod(new Hello(), 'GET')).eq('GET')
expect(getMethod(new Hello(), 'PUT')).eq('PUT')
})
});

0 comments on commit 1a25375

Please sign in to comment.