@appolo/agent
Advanced tools
Comparing version 8.0.4 to 8.0.5
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createAgent = exports.Events = exports.Hooks = exports.Methods = exports.Response = exports.Request = exports.NotFoundError = exports.UnauthorizedError = exports.InternalServerError = exports.BadRequestError = exports.HttpError = exports.Agent = void 0; | ||
exports.createAgent = exports.Events = exports.Hooks = exports.HooksTypes = exports.Methods = exports.Response = exports.Request = exports.NotFoundError = exports.UnauthorizedError = exports.InternalServerError = exports.BadRequestError = exports.HttpError = exports.Agent = void 0; | ||
const agent_1 = require("./lib/agent"); | ||
@@ -23,2 +23,4 @@ var agent_2 = require("./lib/agent"); | ||
Object.defineProperty(exports, "Methods", { enumerable: true, get: function () { return router_1.Methods; } }); | ||
var types_1 = require("./lib/types"); | ||
Object.defineProperty(exports, "HooksTypes", { enumerable: true, get: function () { return types_1.HooksTypes; } }); | ||
var hooks_1 = require("./lib/events/hooks"); | ||
@@ -25,0 +27,0 @@ Object.defineProperty(exports, "Hooks", { enumerable: true, get: function () { return hooks_1.Hooks; } }); |
import {IOptions} from "./lib/IOptions"; | ||
import {Agent} from "./lib/agent"; | ||
import {MiddlewareHandler, MiddlewareHandlerAny, MiddlewareHandlerParams, NextFn} from "./lib/types"; | ||
import {HooksTypes, MiddlewareHandler, MiddlewareHandlerAny, MiddlewareHandlerParams, NextFn} from "./lib/types"; | ||
import {NotFoundError} from "./lib/errors/notFoundError"; | ||
@@ -26,3 +26,3 @@ import {UnauthorizedError} from "./lib/errors/unauthorizedError"; | ||
MiddlewareHandlerErrorOrAny, | ||
MiddlewareHandlerOrAny, | ||
MiddlewareHandlerOrAny,HooksTypes | ||
} from './lib/types' | ||
@@ -29,0 +29,0 @@ export {Hooks} from './lib/events/hooks'; |
@@ -15,27 +15,31 @@ "use strict"; | ||
onError(...hook) { | ||
this._hooks[types_1.HooksTypes.OnError].push(...hook); | ||
this.addHook(types_1.HooksTypes.OnError, ...hook); | ||
return this; | ||
} | ||
onRequest(...hook) { | ||
this._hooks[types_1.HooksTypes.OnRequest].push(...hook); | ||
this.addHook(types_1.HooksTypes.OnRequest, ...hook); | ||
return this; | ||
} | ||
onPreMiddleware(...hook) { | ||
this._hooks[types_1.HooksTypes.PreMiddleware].push(...hook); | ||
this.addHook(types_1.HooksTypes.PreMiddleware, ...hook); | ||
return this; | ||
} | ||
onPreHandler(...hook) { | ||
this._hooks[types_1.HooksTypes.PreHandler].push(...hook); | ||
this.addHook(types_1.HooksTypes.PreHandler, ...hook); | ||
return this; | ||
} | ||
onResponse(...hook) { | ||
this._hooks[types_1.HooksTypes.OnResponse].push(...hook); | ||
this.addHook(types_1.HooksTypes.OnResponse, ...hook); | ||
return this; | ||
} | ||
onSend(...hook) { | ||
this._hooks[types_1.HooksTypes.OnSend].push(...hook); | ||
this.addHook(types_1.HooksTypes.OnSend, ...hook); | ||
return this; | ||
} | ||
addHook(name, ...hook) { | ||
this._hooks[name].push(...hook); | ||
return this; | ||
} | ||
} | ||
exports.Hooks = Hooks; | ||
//# sourceMappingURL=hooks.js.map |
@@ -18,3 +18,3 @@ import {HooksTypes, IHook, IHooks, MiddlewareHandler, MiddlewareHandlerData, MiddlewareHandlerError} from "../types"; | ||
public onError(...hook: MiddlewareHandlerError[]):this { | ||
this._hooks[HooksTypes.OnError].push(...hook); | ||
this.addHook(HooksTypes.OnError,...hook); | ||
return this | ||
@@ -24,3 +24,3 @@ } | ||
public onRequest(...hook: MiddlewareHandler[]):this { | ||
this._hooks[HooksTypes.OnRequest].push(...hook); | ||
this.addHook(HooksTypes.OnRequest,...hook); | ||
return this | ||
@@ -30,3 +30,3 @@ } | ||
public onPreMiddleware(...hook: MiddlewareHandler[]):this { | ||
this._hooks[HooksTypes.PreMiddleware].push(...hook); | ||
this.addHook(HooksTypes.PreMiddleware,...hook); | ||
return this; | ||
@@ -36,3 +36,3 @@ } | ||
public onPreHandler(...hook: MiddlewareHandler[]):this { | ||
this._hooks[HooksTypes.PreHandler].push(...hook); | ||
this.addHook(HooksTypes.PreHandler,...hook); | ||
return this | ||
@@ -42,3 +42,3 @@ } | ||
public onResponse(...hook: MiddlewareHandler[]):this { | ||
this._hooks[HooksTypes.OnResponse].push(...hook); | ||
this.addHook(HooksTypes.OnResponse,...hook); | ||
return this | ||
@@ -48,6 +48,17 @@ } | ||
public onSend(...hook: MiddlewareHandlerData[]):this { | ||
this._hooks[HooksTypes.OnSend].push(...hook); | ||
this.addHook(HooksTypes.OnSend,...hook); | ||
return this | ||
} | ||
public addHook(name: HooksTypes.OnError, ...hook: MiddlewareHandlerError[]): this | ||
public addHook(name: HooksTypes.OnResponse | HooksTypes.PreMiddleware | HooksTypes.PreHandler | HooksTypes.OnRequest, ...hook: MiddlewareHandler[]): this | ||
public addHook(name: HooksTypes.OnSend, ...hook: MiddlewareHandlerData[]): this | ||
public addHook(name: HooksTypes, ...hook: IHook[]): this { | ||
this._hooks[name].push(...hook); | ||
return this | ||
} | ||
} |
@@ -30,3 +30,3 @@ { | ||
"main": "./index.js", | ||
"version": "8.0.4", | ||
"version": "8.0.5", | ||
"license": "MIT", | ||
@@ -33,0 +33,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
118077
2045