simple-boot-http-server
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -33,31 +33,41 @@ import 'reflect-metadata'; | ||
}; | ||
export declare const UrlMapping: (config: MappingConfig) => ReflectMethod; | ||
export declare function UrlMapping(config: MappingConfig): ReflectMethod; | ||
export declare function UrlMapping(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; | ||
export declare const getUrlMapping: (target: any, propertyKey: string | symbol) => MappingConfig | undefined; | ||
export declare const getUrlMappings: (target: any) => SaveMappingConfig[]; | ||
export declare const GET: (inputConfig?: Omit<MappingConfig, 'method'>) => ReflectMethod; | ||
export declare function GET(config: Omit<MappingConfig, 'method'>): ReflectMethod; | ||
export declare function GET(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; | ||
export declare const getGET: (target: any, propertyKey: string | symbol) => MappingConfig | undefined; | ||
export declare const getGETS: (target: any) => SaveMappingConfig[]; | ||
export declare const POST: (inputConfig?: Omit<MappingConfig, 'method'>) => ReflectMethod; | ||
export declare function POST(config: Omit<MappingConfig, 'method'>): ReflectMethod; | ||
export declare function POST(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; | ||
export declare const getPOST: (target: any, propertyKey: string | symbol) => MappingConfig | undefined; | ||
export declare const getPOSTS: (target: any) => SaveMappingConfig[]; | ||
export declare const DELETE: (inputConfig?: Omit<MappingConfig, 'method'>) => ReflectMethod; | ||
export declare function DELETE(config: Omit<MappingConfig, 'method'>): ReflectMethod; | ||
export declare function DELETE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; | ||
export declare const getDELETE: (target: any, propertyKey: string | symbol) => MappingConfig | undefined; | ||
export declare const getDELETES: (target: any) => SaveMappingConfig[]; | ||
export declare const PUT: (inputConfig?: Omit<MappingConfig, 'method'>) => ReflectMethod; | ||
export declare function PUT(config: Omit<MappingConfig, 'method'>): ReflectMethod; | ||
export declare function PUT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; | ||
export declare const getPUT: (target: any, propertyKey: string | symbol) => MappingConfig | undefined; | ||
export declare const getPUTS: (target: any) => SaveMappingConfig[]; | ||
export declare const PATCH: (inputConfig?: Omit<MappingConfig, 'method'>) => ReflectMethod; | ||
export declare function PATCH(config: Omit<MappingConfig, 'method'>): ReflectMethod; | ||
export declare function PATCH(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; | ||
export declare const getPATCH: (target: any, propertyKey: string | symbol) => MappingConfig | undefined; | ||
export declare const getPATCHS: (target: any) => SaveMappingConfig[]; | ||
export declare const OPTIONS: (inputConfig?: Omit<MappingConfig, 'method'>) => ReflectMethod; | ||
export declare function OPTIONS(config: Omit<MappingConfig, 'method'>): ReflectMethod; | ||
export declare function OPTIONS(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; | ||
export declare const getOPTIONS: (target: any, propertyKey: string | symbol) => MappingConfig | undefined; | ||
export declare const getOPTIONSS: (target: any) => SaveMappingConfig[]; | ||
export declare const HEAD: (inputConfig?: Omit<MappingConfig, 'method'>) => ReflectMethod; | ||
export declare function HEAD(config: Omit<MappingConfig, 'method'>): ReflectMethod; | ||
export declare function HEAD(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; | ||
export declare const getHEAD: (target: any, propertyKey: string | symbol) => MappingConfig | undefined; | ||
export declare const getHEADS: (target: any) => SaveMappingConfig[]; | ||
export declare const TRACE: (inputConfig?: Omit<MappingConfig, 'method'>) => ReflectMethod; | ||
export declare function TRACE(config: Omit<MappingConfig, 'method'>): ReflectMethod; | ||
export declare function TRACE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; | ||
export declare const getTRACE: (target: any, propertyKey: string | symbol) => MappingConfig | undefined; | ||
export declare const getTRACES: (target: any) => SaveMappingConfig[]; | ||
export declare const CONNECT: (inputConfig?: Omit<MappingConfig, 'method'>) => ReflectMethod; | ||
export declare function CONNECT(config: Omit<MappingConfig, 'method'>): ReflectMethod; | ||
export declare function CONNECT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; | ||
export declare const getCONNECT: (target: any, propertyKey: string | symbol) => MappingConfig | undefined; | ||
export declare const getCONNECTS: (target: any) => SaveMappingConfig[]; |
@@ -13,11 +13,19 @@ "use strict"; | ||
var MappingMetadataKey = Symbol('MappingMetadataKey'); | ||
var UrlMapping = function (config) { | ||
return function (target, propertyKey, descriptor) { | ||
var _a; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
var process = function (config, target, propertyKey, descriptor) { | ||
var _a; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
function UrlMapping(configOrtarget, propertyKey, descriptor) { | ||
if (propertyKey && descriptor) { | ||
process({ method: HttpMethod_1.HttpMethod.GET }, configOrtarget, propertyKey, descriptor); | ||
} | ||
else { | ||
return function (target, propertyKey, descriptor) { | ||
process(configOrtarget, target, propertyKey, descriptor); | ||
}; | ||
} | ||
} | ||
exports.UrlMapping = UrlMapping; | ||
@@ -35,14 +43,13 @@ var getUrlMapping = function (target, propertyKey) { | ||
exports.getUrlMappings = getUrlMappings; | ||
var GET = function (inputConfig) { | ||
if (inputConfig === void 0) { inputConfig = {}; } | ||
return function (target, propertyKey, descriptor) { | ||
var _a; | ||
var config = inputConfig; | ||
config.method = HttpMethod_1.HttpMethod.GET; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
}; | ||
function GET(configOrTarget, propertyKey, descriptor) { | ||
if (propertyKey && descriptor) { | ||
process({ method: HttpMethod_1.HttpMethod.GET }, configOrTarget, propertyKey, descriptor); | ||
} | ||
else { | ||
return function (target, propertyKey, descriptor) { | ||
configOrTarget.method = HttpMethod_1.HttpMethod.GET; | ||
process(configOrTarget, target, propertyKey, descriptor); | ||
}; | ||
} | ||
} | ||
exports.GET = GET; | ||
@@ -58,14 +65,13 @@ var getGET = function (target, propertyKey) { | ||
exports.getGETS = getGETS; | ||
var POST = function (inputConfig) { | ||
if (inputConfig === void 0) { inputConfig = {}; } | ||
return function (target, propertyKey, descriptor) { | ||
var _a; | ||
var config = inputConfig; | ||
config.method = HttpMethod_1.HttpMethod.POST; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
}; | ||
function POST(configOrTarget, propertyKey, descriptor) { | ||
if (propertyKey && descriptor) { | ||
process({ method: HttpMethod_1.HttpMethod.POST }, configOrTarget, propertyKey, descriptor); | ||
} | ||
else { | ||
return function (target, propertyKey, descriptor) { | ||
configOrTarget.method = HttpMethod_1.HttpMethod.POST; | ||
process(configOrTarget, target, propertyKey, descriptor); | ||
}; | ||
} | ||
} | ||
exports.POST = POST; | ||
@@ -81,14 +87,13 @@ var getPOST = function (target, propertyKey) { | ||
exports.getPOSTS = getPOSTS; | ||
var DELETE = function (inputConfig) { | ||
if (inputConfig === void 0) { inputConfig = {}; } | ||
return function (target, propertyKey, descriptor) { | ||
var _a; | ||
var config = inputConfig; | ||
config.method = HttpMethod_1.HttpMethod.DELETE; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
}; | ||
function DELETE(configOrTarget, propertyKey, descriptor) { | ||
if (propertyKey && descriptor) { | ||
process({ method: HttpMethod_1.HttpMethod.DELETE }, configOrTarget, propertyKey, descriptor); | ||
} | ||
else { | ||
return function (target, propertyKey, descriptor) { | ||
configOrTarget.method = HttpMethod_1.HttpMethod.DELETE; | ||
process(configOrTarget, target, propertyKey, descriptor); | ||
}; | ||
} | ||
} | ||
exports.DELETE = DELETE; | ||
@@ -104,14 +109,13 @@ var getDELETE = function (target, propertyKey) { | ||
exports.getDELETES = getDELETES; | ||
var PUT = function (inputConfig) { | ||
if (inputConfig === void 0) { inputConfig = {}; } | ||
return function (target, propertyKey, descriptor) { | ||
var _a; | ||
var config = inputConfig; | ||
config.method = HttpMethod_1.HttpMethod.PUT; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
}; | ||
function PUT(configOrTarget, propertyKey, descriptor) { | ||
if (propertyKey && descriptor) { | ||
process({ method: HttpMethod_1.HttpMethod.PUT }, configOrTarget, propertyKey, descriptor); | ||
} | ||
else { | ||
return function (target, propertyKey, descriptor) { | ||
configOrTarget.method = HttpMethod_1.HttpMethod.PUT; | ||
process(configOrTarget, target, propertyKey, descriptor); | ||
}; | ||
} | ||
} | ||
exports.PUT = PUT; | ||
@@ -127,14 +131,13 @@ var getPUT = function (target, propertyKey) { | ||
exports.getPUTS = getPUTS; | ||
var PATCH = function (inputConfig) { | ||
if (inputConfig === void 0) { inputConfig = {}; } | ||
return function (target, propertyKey, descriptor) { | ||
var _a; | ||
var config = inputConfig; | ||
config.method = HttpMethod_1.HttpMethod.PATCH; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
}; | ||
function PATCH(configOrTarget, propertyKey, descriptor) { | ||
if (propertyKey && descriptor) { | ||
process({ method: HttpMethod_1.HttpMethod.PATCH }, configOrTarget, propertyKey, descriptor); | ||
} | ||
else { | ||
return function (target, propertyKey, descriptor) { | ||
configOrTarget.method = HttpMethod_1.HttpMethod.PATCH; | ||
process(configOrTarget, target, propertyKey, descriptor); | ||
}; | ||
} | ||
} | ||
exports.PATCH = PATCH; | ||
@@ -150,14 +153,13 @@ var getPATCH = function (target, propertyKey) { | ||
exports.getPATCHS = getPATCHS; | ||
var OPTIONS = function (inputConfig) { | ||
if (inputConfig === void 0) { inputConfig = {}; } | ||
return function (target, propertyKey, descriptor) { | ||
var _a; | ||
var config = inputConfig; | ||
config.method = HttpMethod_1.HttpMethod.OPTIONS; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
}; | ||
function OPTIONS(configOrTarget, propertyKey, descriptor) { | ||
if (propertyKey && descriptor) { | ||
process({ method: HttpMethod_1.HttpMethod.OPTIONS }, configOrTarget, propertyKey, descriptor); | ||
} | ||
else { | ||
return function (target, propertyKey, descriptor) { | ||
configOrTarget.method = HttpMethod_1.HttpMethod.OPTIONS; | ||
process(configOrTarget, target, propertyKey, descriptor); | ||
}; | ||
} | ||
} | ||
exports.OPTIONS = OPTIONS; | ||
@@ -173,14 +175,13 @@ var getOPTIONS = function (target, propertyKey) { | ||
exports.getOPTIONSS = getOPTIONSS; | ||
var HEAD = function (inputConfig) { | ||
if (inputConfig === void 0) { inputConfig = {}; } | ||
return function (target, propertyKey, descriptor) { | ||
var _a; | ||
var config = inputConfig; | ||
config.method = HttpMethod_1.HttpMethod.HEAD; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
}; | ||
function HEAD(configOrTarget, propertyKey, descriptor) { | ||
if (propertyKey && descriptor) { | ||
process({ method: HttpMethod_1.HttpMethod.HEAD }, configOrTarget, propertyKey, descriptor); | ||
} | ||
else { | ||
return function (target, propertyKey, descriptor) { | ||
configOrTarget.method = HttpMethod_1.HttpMethod.HEAD; | ||
process(configOrTarget, target, propertyKey, descriptor); | ||
}; | ||
} | ||
} | ||
exports.HEAD = HEAD; | ||
@@ -196,14 +197,13 @@ var getHEAD = function (target, propertyKey) { | ||
exports.getHEADS = getHEADS; | ||
var TRACE = function (inputConfig) { | ||
if (inputConfig === void 0) { inputConfig = {}; } | ||
return function (target, propertyKey, descriptor) { | ||
var _a; | ||
var config = inputConfig; | ||
config.method = HttpMethod_1.HttpMethod.TRACE; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
}; | ||
function TRACE(configOrTarget, propertyKey, descriptor) { | ||
if (propertyKey && descriptor) { | ||
process({ method: HttpMethod_1.HttpMethod.TRACE }, configOrTarget, propertyKey, descriptor); | ||
} | ||
else { | ||
return function (target, propertyKey, descriptor) { | ||
configOrTarget.method = HttpMethod_1.HttpMethod.TRACE; | ||
process(configOrTarget, target, propertyKey, descriptor); | ||
}; | ||
} | ||
} | ||
exports.TRACE = TRACE; | ||
@@ -219,14 +219,13 @@ var getTRACE = function (target, propertyKey) { | ||
exports.getTRACES = getTRACES; | ||
var CONNECT = function (inputConfig) { | ||
if (inputConfig === void 0) { inputConfig = {}; } | ||
return function (target, propertyKey, descriptor) { | ||
var _a; | ||
var config = inputConfig; | ||
config.method = HttpMethod_1.HttpMethod.CONNECT; | ||
var saveMappingConfigs = ((_a = ReflectUtils_1.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor)) !== null && _a !== void 0 ? _a : []); | ||
saveMappingConfigs.push({ propertyKey: propertyKey, config: config }); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey); | ||
}; | ||
}; | ||
function CONNECT(configOrTarget, propertyKey, descriptor) { | ||
if (propertyKey && descriptor) { | ||
process({ method: HttpMethod_1.HttpMethod.CONNECT }, configOrTarget, propertyKey, descriptor); | ||
} | ||
else { | ||
return function (target, propertyKey, descriptor) { | ||
configOrTarget.method = HttpMethod_1.HttpMethod.CONNECT; | ||
process(configOrTarget, target, propertyKey, descriptor); | ||
}; | ||
} | ||
} | ||
exports.CONNECT = CONNECT; | ||
@@ -233,0 +232,0 @@ var getCONNECT = function (target, propertyKey) { |
@@ -7,3 +7,3 @@ import { Filter } from '../filters/Filter'; | ||
private resourceRegex; | ||
constructor(resourceDistPath: string, resourceRegex?: string[]); | ||
constructor(resourceDistPath: string, resourceRegex?: (string | RegExp)[]); | ||
onInit(app: SimpleBootHttpServer): Promise<void>; | ||
@@ -10,0 +10,0 @@ before(rr: RequestResponse, app: SimpleBootHttpServer): Promise<boolean>; |
@@ -70,3 +70,5 @@ "use strict"; | ||
sw = true; | ||
regExps = this.resourceRegex.filter(function (it) { return RegExp(it).test(url); }); | ||
regExps = this.resourceRegex.filter(function (it) { | ||
return it instanceof RegExp ? it.test(url) : RegExp(it).test(url); | ||
}); | ||
_i = 0, regExps_1 = regExps; | ||
@@ -73,0 +75,0 @@ _b.label = 1; |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { IncomingMessage, OutgoingHttpHeader, OutgoingHttpHeaders, ServerResponse } from 'http'; | ||
@@ -62,3 +64,3 @@ import { HttpHeaders } from '../codes/HttpHeaders'; | ||
resWriteJson(chunk: any, encoding?: BufferEncoding): RequestResponseChain<any>; | ||
resSetHeader(key: HttpHeaders | string, value: string | string[]): RequestResponseChain<ServerResponse>; | ||
resSetHeader(key: HttpHeaders | string, value: string | string[]): RequestResponseChain<ServerResponse<IncomingMessage>>; | ||
resSetHeaders(headers: { | ||
@@ -70,3 +72,3 @@ [key: string]: string | string[]; | ||
[key: string]: string | string[]; | ||
}): RequestResponseChain<ServerResponse>; | ||
}): RequestResponseChain<ServerResponse<IncomingMessage>>; | ||
resIsDone(): boolean; | ||
@@ -73,0 +75,0 @@ createRequestResponseChain<T = any>(data?: T): RequestResponseChain<T>; |
{ | ||
"name": "simple-boot-http-server", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"main": "SimpleBootHttpServer.js", | ||
@@ -83,4 +83,4 @@ "license": "MIT", | ||
"mime-types": "^2.1.34", | ||
"simple-boot-core": "^1.0.32" | ||
"simple-boot-core": "^1.0.36" | ||
} | ||
} |
@@ -140,3 +140,3 @@ SIMPLE-BOOT-HTTP-SERVER | ||
@Sim() | ||
@Sim | ||
export class Advice { | ||
@@ -168,3 +168,3 @@ @ExceptionHandler({type: NotFoundError}) | ||
```typescript | ||
@Sim() | ||
@Sim | ||
class CloseEndPoint implements EndPoint { | ||
@@ -175,3 +175,3 @@ async endPoint(rr: RequestResponse, app: SimpleBootHttpServer) { | ||
} | ||
@Sim() | ||
@Sim | ||
class ErrorEndPoint implements EndPoint { | ||
@@ -178,0 +178,0 @@ async endPoint(rr: RequestResponse, app: SimpleBootHttpServer) { |
135395
64
2647
2
Updatedsimple-boot-core@^1.0.36