@bunt/app
Advanced tools
Comparing version 0.23.0 to 0.24.0
@@ -8,3 +8,3 @@ import { ActionAny, ApplyContext, Context, ContextArg, Unit } from "@bunt/unit"; | ||
protected logger: Logger; | ||
constructor(u: Unit<C>, routes?: IRoute<ActionAny<C>>[]); | ||
constructor(unit: Unit<C>, routes?: IRoute<ActionAny<C>>[]); | ||
get context(): ApplyContext<C>; | ||
@@ -11,0 +11,0 @@ get size(): number; |
@@ -19,3 +19,3 @@ "use strict"; | ||
}; | ||
var _Application_unit, _Application_routes; | ||
var _Application_unit, _Application_routes, _Application_index; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -27,6 +27,7 @@ exports.Application = void 0; | ||
class Application { | ||
constructor(u, routes = []) { | ||
constructor(unit, routes = []) { | ||
_Application_unit.set(this, void 0); | ||
_Application_routes.set(this, []); | ||
__classPrivateFieldSet(this, _Application_unit, u, "f"); | ||
_Application_routes.set(this, new Set()); | ||
_Application_index.set(this, []); | ||
__classPrivateFieldSet(this, _Application_unit, unit, "f"); | ||
if (routes.length > 0) { | ||
@@ -40,3 +41,3 @@ routes.forEach((route) => this.add(route)); | ||
get size() { | ||
return __classPrivateFieldGet(this, _Application_routes, "f").length; | ||
return __classPrivateFieldGet(this, _Application_routes, "f").size; | ||
} | ||
@@ -48,18 +49,16 @@ static async factory(context, routes = []) { | ||
this.logger.debug("add", route); | ||
(0, util_1.assert)(!__classPrivateFieldGet(this, _Application_unit, "f").has(route.action), "This route was already added"); | ||
__classPrivateFieldGet(this, _Application_unit, "f").add(route.action); | ||
__classPrivateFieldGet(this, _Application_routes, "f").push(route); | ||
(0, util_1.assert)(!__classPrivateFieldGet(this, _Application_routes, "f").has(route), `Duplicate route: ${route.route}`); | ||
__classPrivateFieldGet(this, _Application_routes, "f").add(route); | ||
__classPrivateFieldGet(this, _Application_index, "f").push(route); | ||
return this; | ||
} | ||
remove(route) { | ||
if (__classPrivateFieldGet(this, _Application_unit, "f").has(route.action)) { | ||
this.logger.debug("remove", route); | ||
__classPrivateFieldGet(this, _Application_unit, "f").remove(route.action); | ||
const index = __classPrivateFieldGet(this, _Application_routes, "f").findIndex((item) => item === route); | ||
__classPrivateFieldGet(this, _Application_routes, "f").splice(index, index + 1); | ||
} | ||
this.logger.debug("remove", route); | ||
__classPrivateFieldGet(this, _Application_routes, "f").delete(route); | ||
__classPrivateFieldGet(this, _Application_index, "f").length = 0; | ||
__classPrivateFieldGet(this, _Application_index, "f").push(...__classPrivateFieldGet(this, _Application_routes, "f").values()); | ||
return this; | ||
} | ||
async run(request) { | ||
const route = __classPrivateFieldGet(this, _Application_routes, "f").find((route) => route.test(request.route)); | ||
const route = __classPrivateFieldGet(this, _Application_index, "f").find((route) => route.test(request.route)); | ||
(0, util_1.assert)(route, () => new Route_1.RouteNotFound(request.route)); | ||
@@ -83,6 +82,6 @@ this.logger.debug("match", route); | ||
getRoutes() { | ||
return __classPrivateFieldGet(this, _Application_routes, "f"); | ||
return __classPrivateFieldGet(this, _Application_index, "f"); | ||
} | ||
} | ||
_Application_unit = new WeakMap(), _Application_routes = new WeakMap(); | ||
_Application_unit = new WeakMap(), _Application_routes = new WeakMap(), _Application_index = new WeakMap(); | ||
__decorate([ | ||
@@ -89,0 +88,0 @@ util_1.logger |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -1,2 +0,2 @@ | ||
import { ActionAny, ActionContext, ActionCtor, ActionState, ApplyContext } from "@bunt/unit"; | ||
import { ActionAny, ActionContext, ActionFactory, ActionState, ApplyContext } from "@bunt/unit"; | ||
import { Ctor } from "@bunt/util"; | ||
@@ -9,3 +9,3 @@ import { IRequest } from "../interfaces"; | ||
readonly route: string; | ||
readonly action: ActionCtor<any>; | ||
readonly action: ActionFactory<any>; | ||
readonly payload?: Payload<A>; | ||
@@ -12,0 +12,0 @@ test(route: string): boolean; |
@@ -1,3 +0,3 @@ | ||
import { ActionAny } from "@bunt/unit"; | ||
import { Ctor, ILogable } from "@bunt/util"; | ||
import { ActionAny, ActionFactory } from "@bunt/unit"; | ||
import { ILogable } from "@bunt/util"; | ||
import { IRoute, RouteFactory, RouteMatcherFactory, RouteRuleArg } from "./interfaces"; | ||
@@ -10,5 +10,5 @@ import { RouteRule } from "./RouteRule"; | ||
readonly route: string; | ||
readonly action: Ctor<A>; | ||
readonly action: ActionFactory<any>; | ||
readonly payload?: RouteRule<A>; | ||
constructor(matcher: RouteMatcherFactory, action: Ctor<A>, rule: RouteRuleArg<A>); | ||
constructor(matcher: RouteMatcherFactory, action: ActionFactory<any>, rule: RouteRuleArg<A>); | ||
static create(matcher: RouteMatcherFactory): RouteFactory; | ||
@@ -15,0 +15,0 @@ getLogValue(): { |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
{ | ||
"name": "@bunt/app", | ||
"version": "0.23.0", | ||
"version": "0.24.0", | ||
"keywords": [ | ||
@@ -29,9 +29,9 @@ "typescript" | ||
"dependencies": { | ||
"@bunt/input": "^0.23.0", | ||
"@bunt/unit": "^0.23.0", | ||
"@bunt/util": "^0.23.0", | ||
"@bunt/input": "^0.24.0", | ||
"@bunt/unit": "^0.24.0", | ||
"@bunt/util": "^0.24.0", | ||
"path-to-regexp": "^6.2.0" | ||
}, | ||
"license": "MIT", | ||
"gitHead": "764859d453226d6f229675eb6bcce3bd56c43428" | ||
"gitHead": "870927e58da8dcc164c48be4bb13ddb171c5b1fd" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
49425
809
+ Added@bunt/input@0.24.55(transitive)
+ Added@bunt/unit@0.24.53(transitive)
+ Added@bunt/util@0.24.53(transitive)
- Removed@bunt/input@0.23.0(transitive)
- Removed@bunt/unit@0.23.0(transitive)
- Removed@bunt/util@0.23.0(transitive)
Updated@bunt/input@^0.24.0
Updated@bunt/unit@^0.24.0
Updated@bunt/util@^0.24.0