@adonisjs/http-server
Advanced tools
Comparing version 2.0.3 to 2.1.0
@@ -179,4 +179,13 @@ declare module '@ioc:Adonis/Core/Route' { | ||
prefixDomain?: boolean; | ||
} & { | ||
[key: string]: any; | ||
}; | ||
/** | ||
* Options for making a signed url | ||
*/ | ||
export type MakeSignedUrlOptions = MakeUrlOptions & { | ||
expiresIn?: string | number; | ||
purpose?: string; | ||
}; | ||
/** | ||
* Shape of router exposed for creating routes | ||
@@ -207,6 +216,3 @@ */ | ||
makeUrl(routeIdentifier: string, options?: MakeUrlOptions, domain?: string): string | null; | ||
makeSignedUrl(routeIdentifier: string, options?: MakeUrlOptions & { | ||
expiresIn?: string | number; | ||
purpose?: string; | ||
}, domain?: string): string | null; | ||
makeSignedUrl(routeIdentifier: string, options?: MakeSignedUrlOptions, domain?: string): string | null; | ||
forTesting(pattern?: string, methods?: string[], handler?: any): RouteContract; | ||
@@ -213,0 +219,0 @@ } |
@@ -6,3 +6,3 @@ /// <reference path="../adonis-typings/index.d.ts" /> | ||
import { RouteResource } from './Router/Resource'; | ||
import { RouteJSON } from '@ioc:Adonis/Core/Route'; | ||
import { RouteJSON, MakeUrlOptions, MakeSignedUrlOptions } from '@ioc:Adonis/Core/Route'; | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | ||
@@ -33,1 +33,14 @@ /** | ||
export declare function trustProxy(remoteAddress: string, proxyFn: (addr: string, distance: number) => boolean): boolean; | ||
/** | ||
* Normalizes the make url options by allowing params to appear on | ||
* top level object with option to nest inside `params` property. | ||
*/ | ||
export declare function normalizeMakeUrlOptions(options?: MakeUrlOptions): Required<MakeUrlOptions>; | ||
/** | ||
* Normalizes the make signed url options by allowing params to appear on | ||
* top level object with option to nest inside `params` property. | ||
*/ | ||
export declare function normalizeMakeSignedUrlOptions(options?: MakeSignedUrlOptions): Required<MakeUrlOptions> & { | ||
purpose?: string; | ||
expiresIn?: string | number; | ||
}; |
@@ -115,1 +115,34 @@ "use strict"; | ||
exports.trustProxy = trustProxy; | ||
/** | ||
* Normalizes the make url options by allowing params to appear on | ||
* top level object with option to nest inside `params` property. | ||
*/ | ||
function normalizeMakeUrlOptions(options) { | ||
const params = options ? (options.params ? options.params : options) : {}; | ||
const qs = options && options.qs ? options.qs : {}; | ||
const domainParams = options && options.domainParams ? options.domainParams : {}; | ||
const prefixDomain = options && options.prefixDomain !== undefined ? options.prefixDomain : true; | ||
return { params, qs, domainParams, prefixDomain }; | ||
} | ||
exports.normalizeMakeUrlOptions = normalizeMakeUrlOptions; | ||
/** | ||
* Normalizes the make signed url options by allowing params to appear on | ||
* top level object with option to nest inside `params` property. | ||
*/ | ||
function normalizeMakeSignedUrlOptions(options) { | ||
const params = options ? (options.params ? options.params : options) : {}; | ||
const qs = options && options.qs ? options.qs : {}; | ||
const domainParams = options && options.domainParams ? options.domainParams : {}; | ||
const prefixDomain = options && options.prefixDomain !== undefined ? options.prefixDomain : true; | ||
const expiresIn = options && options.expiresIn !== undefined ? options.expiresIn : undefined; | ||
const purpose = options && options.purpose ? options.purpose : undefined; | ||
return { | ||
params, | ||
qs, | ||
domainParams, | ||
prefixDomain, | ||
expiresIn, | ||
purpose, | ||
}; | ||
} | ||
exports.normalizeMakeSignedUrlOptions = normalizeMakeSignedUrlOptions; |
/// <reference path="../../adonis-typings/index.d.ts" /> | ||
/// <reference path="../../adonis-typings/route.d.ts" /> | ||
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption'; | ||
import { RouteNode, MatchedRoute, RouterContract, MakeUrlOptions, RouteLookupNode, RouteHandler } from '@ioc:Adonis/Core/Route'; | ||
import { RouteNode, RouteHandler, MatchedRoute, RouterContract, MakeUrlOptions, RouteLookupNode, MakeSignedUrlOptions } from '@ioc:Adonis/Core/Route'; | ||
import { Route } from './Route'; | ||
@@ -142,6 +142,3 @@ import { RouteGroup } from './Group'; | ||
*/ | ||
makeSignedUrl(routeIdentifier: string, options?: MakeUrlOptions & { | ||
expiresIn?: string | number; | ||
purpose?: string; | ||
}, domain?: string): string | null; | ||
makeSignedUrl(routeIdentifier: string, options?: MakeSignedUrlOptions, domain?: string): string | null; | ||
/** | ||
@@ -148,0 +145,0 @@ * Creates a route when writing tests and auto-commits it to the |
@@ -321,3 +321,3 @@ "use strict"; | ||
*/ | ||
options = Object.assign({ qs: {}, params: {}, domainParams: {}, prefixDomain: true }, options); | ||
options = helpers_1.normalizeMakeUrlOptions(options); | ||
/** | ||
@@ -347,3 +347,3 @@ * Processing the route pattern with dynamic segments | ||
} | ||
options = Object.assign({ qs: {}, params: {}, domainParams: {}, prefixDomain: true }, options); | ||
options = helpers_1.normalizeMakeSignedUrlOptions(options); | ||
/** | ||
@@ -350,0 +350,0 @@ * Making the signature from the qualified url. We do not prefix the domain when |
@@ -69,3 +69,3 @@ "use strict"; | ||
this.makeRoute(`${this.shallow ? mainResource : fullUrl}/:id`, ['PUT', 'PATCH'], 'update'); | ||
this.makeRoute(`${this.shallow ? mainResource : fullUrl}/:id`, ['DELETE'], 'delete'); | ||
this.makeRoute(`${this.shallow ? mainResource : fullUrl}/:id`, ['DELETE'], 'destroy'); | ||
} | ||
@@ -72,0 +72,0 @@ /** |
{ | ||
"name": "@adonisjs/http-server", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "AdonisJS HTTP server with support packed with Routing and Cookies", | ||
@@ -42,3 +42,3 @@ "main": "build/providers/HttpServerProvider.js", | ||
"@types/ms": "^0.7.31", | ||
"@types/node": "^13.11.1", | ||
"@types/node": "^13.13.0", | ||
"@types/pluralize": "0.0.29", | ||
@@ -45,0 +45,0 @@ "@types/proxy-addr": "^2.0.0", |
245158
7022