@bunt/app
Advanced tools
Comparing version 0.26.3 to 0.27.0
@@ -12,2 +12,4 @@ "use strict"; | ||
const util_1 = require("@bunt/util"); | ||
const assert_1 = require("@bunt/assert"); | ||
const is_1 = require("@bunt/is"); | ||
const index_js_1 = require("./Route/index.js"); | ||
@@ -35,3 +37,3 @@ class Application { | ||
this.logger.debug("add", route); | ||
(0, util_1.assert)(!this.#routes.has(route), `Duplicate route: ${route.route}`); | ||
(0, assert_1.assert)(!this.#routes.has(route), `Duplicate route: ${route.route}`); | ||
this.#routes.add(route); | ||
@@ -51,7 +53,7 @@ this.#index.push(route); | ||
const route = this.#index.find((route) => route.test(request.route)); | ||
(0, util_1.assert)(route, () => new index_js_1.RouteNotFound(request.route)); | ||
(0, assert_1.assert)(route, () => new index_js_1.RouteNotFound(request.route)); | ||
this.logger.debug("match", route); | ||
const state = {}; | ||
const matches = route.match(request.route); | ||
if ((0, util_1.isDefined)(route.payload)) { | ||
if ((0, is_1.isDefined)(route.payload)) { | ||
const { payload } = route; | ||
@@ -82,6 +84,6 @@ Object.assign(state, await payload.validate({ | ||
} | ||
exports.Application = Application; | ||
__decorate([ | ||
util_1.logger | ||
], Application.prototype, "logger", void 0); | ||
exports.Application = Application; | ||
//# sourceMappingURL=Application.js.map |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Promisify } from "@bunt/util"; | ||
import { Promisify } from "@bunt/type"; | ||
import { Application } from "./Application.js"; | ||
@@ -5,0 +5,0 @@ export type ActionResponse = Error | { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Resolver = void 0; | ||
const util_1 = require("@bunt/util"); | ||
const is_1 = require("@bunt/is"); | ||
class Resolver { | ||
@@ -13,8 +13,8 @@ resolvers; | ||
const { resolvers } = this; | ||
if ((0, util_1.isFunction)(resolvers)) { | ||
if ((0, is_1.isFunction)(resolvers)) { | ||
Object.assign(state, await resolvers(context)); | ||
} | ||
else if ((0, util_1.isObject)(resolvers)) { | ||
else if ((0, is_1.isObject)(resolvers)) { | ||
for (const [name, resolver] of Object.entries(resolvers)) { | ||
if ((0, util_1.isFunction)(resolver)) { | ||
if ((0, is_1.isFunction)(resolver)) { | ||
Reflect.set(state, name, await resolver(context)); | ||
@@ -21,0 +21,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { ILogable } from "@bunt/util"; | ||
import { ILogable } from "@bunt/type"; | ||
import { HeaderAssertValue, IHeaders } from "../interfaces.js"; | ||
@@ -3,0 +3,0 @@ import { StrictKeyValueMap } from "./StrictKeyValueMap.js"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HeadersAbstract = void 0; | ||
const util_1 = require("@bunt/util"); | ||
const is_1 = require("@bunt/is"); | ||
const assert_1 = require("@bunt/assert"); | ||
const StrictKeyValueMap_js_1 = require("./StrictKeyValueMap.js"); | ||
@@ -10,8 +11,8 @@ class HeadersAbstract extends StrictKeyValueMap_js_1.StrictKeyValueMap { | ||
if (Array.isArray(expected)) { | ||
(0, util_1.assert)(expected.some((e) => clientValue.includes(e)), `Wrong header "${header}" value, allowed: ${expected.join(", ")}`); | ||
(0, assert_1.assert)(expected.some((e) => clientValue.includes(e)), `Wrong header "${header}" value, allowed: ${expected.join(", ")}`); | ||
} | ||
if ((0, util_1.isFunction)(expected)) { | ||
if ((0, is_1.isFunction)(expected)) { | ||
const result = expected(clientValue); | ||
if ((0, util_1.isBoolean)(result)) { | ||
(0, util_1.assert)(result, `Wrong ${header}`); | ||
if ((0, is_1.isBoolean)(result)) { | ||
(0, assert_1.assert)(result, `Wrong ${header}`); | ||
} | ||
@@ -18,0 +19,0 @@ } |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { ILogable, Promisify } from "@bunt/util"; | ||
import { ILogable, Promisify } from "@bunt/type"; | ||
import { Application } from "../Application.js"; | ||
@@ -5,0 +5,0 @@ import { IHeaders, IKeyValueMap, IRequest, IRequestTransform, RequestTransformType } from "../interfaces.js"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RequestAbstract = void 0; | ||
const util_1 = require("@bunt/util"); | ||
const is_1 = require("@bunt/is"); | ||
const index_js_1 = require("../TransformRequest/index.js"); | ||
@@ -24,3 +24,3 @@ class RequestAbstract { | ||
transform(transformer) { | ||
if ((0, util_1.isFunction)(transformer)) { | ||
if ((0, is_1.isFunction)(transformer)) { | ||
return transformer(this); | ||
@@ -27,0 +27,0 @@ } |
import { ActionAny, ActionFactory } from "@bunt/unit"; | ||
import { ILogable } from "@bunt/util"; | ||
import { ILogable } from "@bunt/type"; | ||
import { IRoute, RouteFactory, RouteMatcherFactory, RouteRuleArg } from "./interfaces.js"; | ||
@@ -4,0 +4,0 @@ import { RouteRule } from "./RouteRule.js"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Route = void 0; | ||
const util_1 = require("@bunt/util"); | ||
const is_1 = require("@bunt/is"); | ||
class Route { | ||
@@ -15,3 +15,3 @@ route; | ||
this.payload = payload; | ||
this.#matcher = (0, util_1.isFunction)(matcher) ? matcher(this.route) : matcher; | ||
this.#matcher = (0, is_1.isFunction)(matcher) ? matcher(this.route) : matcher; | ||
} | ||
@@ -37,3 +37,3 @@ /** | ||
getRuleArgs(rule) { | ||
if ((0, util_1.isString)(rule)) { | ||
if ((0, is_1.isString)(rule)) { | ||
return { route: rule, payload: undefined }; | ||
@@ -40,0 +40,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { NotFound } from "@bunt/util"; | ||
import { NotFound } from "@bunt/assert"; | ||
export declare class RouteNotFound extends NotFound { | ||
@@ -3,0 +3,0 @@ constructor(route: string); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RouteNotFound = void 0; | ||
const util_1 = require("@bunt/util"); | ||
class RouteNotFound extends util_1.NotFound { | ||
const assert_1 = require("@bunt/assert"); | ||
class RouteNotFound extends assert_1.NotFound { | ||
constructor(route) { | ||
@@ -7,0 +7,0 @@ super(`Route "${route}" not found`); |
@@ -10,2 +10,3 @@ "use strict"; | ||
const busboy = require("busboy"); | ||
const async_1 = require("@bunt/async"); | ||
const MultipartFormDataTransform = async (request) => { | ||
@@ -15,3 +16,3 @@ request.headers.assert("Content-Type", (value) => value.startsWith("multipart/form-data")); | ||
const rs = await request.createReadableStream(); | ||
const defer = new util_1.Defer(); | ||
const defer = new async_1.Defer(); | ||
const result = {}; | ||
@@ -31,3 +32,3 @@ const pending = []; | ||
inject(parseFieldName(name), value, result); | ||
const def = new util_1.Defer(); | ||
const def = new async_1.Defer(); | ||
pending.push(def); | ||
@@ -34,0 +35,0 @@ file |
@@ -8,3 +8,5 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
import { unit, } from "@bunt/unit"; | ||
import { assert, isDefined, logger } from "@bunt/util"; | ||
import { logger } from "@bunt/util"; | ||
import { assert } from "@bunt/assert"; | ||
import { isDefined } from "@bunt/is"; | ||
import { RouteNotFound } from "./Route/index.js"; | ||
@@ -11,0 +13,0 @@ export class Application { |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Promisify } from "@bunt/util"; | ||
import { Promisify } from "@bunt/type"; | ||
import { Application } from "./Application.js"; | ||
@@ -5,0 +5,0 @@ export type ActionResponse = Error | { |
@@ -1,2 +0,2 @@ | ||
import { isFunction, isObject } from "@bunt/util"; | ||
import { isFunction, isObject } from "@bunt/is"; | ||
export class Resolver { | ||
@@ -3,0 +3,0 @@ resolvers; |
@@ -1,2 +0,2 @@ | ||
import { ILogable } from "@bunt/util"; | ||
import { ILogable } from "@bunt/type"; | ||
import { HeaderAssertValue, IHeaders } from "../interfaces.js"; | ||
@@ -3,0 +3,0 @@ import { StrictKeyValueMap } from "./StrictKeyValueMap.js"; |
@@ -1,2 +0,3 @@ | ||
import { assert, isBoolean, isFunction } from "@bunt/util"; | ||
import { isBoolean, isFunction } from "@bunt/is"; | ||
import { assert } from "@bunt/assert"; | ||
import { StrictKeyValueMap } from "./StrictKeyValueMap.js"; | ||
@@ -3,0 +4,0 @@ export class HeadersAbstract extends StrictKeyValueMap { |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { ILogable, Promisify } from "@bunt/util"; | ||
import { ILogable, Promisify } from "@bunt/type"; | ||
import { Application } from "../Application.js"; | ||
@@ -5,0 +5,0 @@ import { IHeaders, IKeyValueMap, IRequest, IRequestTransform, RequestTransformType } from "../interfaces.js"; |
@@ -1,2 +0,2 @@ | ||
import { isFunction } from "@bunt/util"; | ||
import { isFunction } from "@bunt/is"; | ||
import { fromJsonRequest, fromTextRequest, MultipartFormDataTransform, URLEncodedFormTransform, } from "../TransformRequest/index.js"; | ||
@@ -3,0 +3,0 @@ export class RequestAbstract { |
@@ -1,2 +0,2 @@ | ||
class EqualMatcher { | ||
export class EqualMatcher { | ||
route; | ||
@@ -16,3 +16,2 @@ constructor(route) { | ||
} | ||
export { EqualMatcher }; | ||
//# sourceMappingURL=EqualMatcher.js.map |
import { match, pathToRegexp } from "path-to-regexp"; | ||
class RegexpMatcher { | ||
export class RegexpMatcher { | ||
route; | ||
@@ -21,3 +21,2 @@ matcher; | ||
} | ||
export { RegexpMatcher }; | ||
//# sourceMappingURL=RegexpMatcher.js.map |
import { ActionAny, ActionFactory } from "@bunt/unit"; | ||
import { ILogable } from "@bunt/util"; | ||
import { ILogable } from "@bunt/type"; | ||
import { IRoute, RouteFactory, RouteMatcherFactory, RouteRuleArg } from "./interfaces.js"; | ||
@@ -4,0 +4,0 @@ import { RouteRule } from "./RouteRule.js"; |
@@ -1,2 +0,2 @@ | ||
import { isFunction, isString } from "@bunt/util"; | ||
import { isFunction, isString } from "@bunt/is"; | ||
export class Route { | ||
@@ -3,0 +3,0 @@ route; |
@@ -1,2 +0,2 @@ | ||
import { NotFound } from "@bunt/util"; | ||
import { NotFound } from "@bunt/assert"; | ||
export declare class RouteNotFound extends NotFound { | ||
@@ -3,0 +3,0 @@ constructor(route: string); |
@@ -1,2 +0,2 @@ | ||
import { NotFound } from "@bunt/util"; | ||
import { NotFound } from "@bunt/assert"; | ||
export class RouteNotFound extends NotFound { | ||
@@ -3,0 +3,0 @@ constructor(route) { |
@@ -5,4 +5,5 @@ import { randomBytes } from "crypto"; | ||
import { createWriteStream } from "fs"; | ||
import { Defer, QueryString } from "@bunt/util"; | ||
import { QueryString } from "@bunt/util"; | ||
import * as busboy from "busboy"; | ||
import { Defer } from "@bunt/async"; | ||
export const MultipartFormDataTransform = async (request) => { | ||
@@ -9,0 +10,0 @@ request.headers.assert("Content-Type", (value) => value.startsWith("multipart/form-data")); |
{ | ||
"name": "@bunt/app", | ||
"version": "0.26.3", | ||
"version": "0.27.0", | ||
"keywords": [ | ||
@@ -36,5 +36,8 @@ "typescript" | ||
"dependencies": { | ||
"@bunt/input": "^0.26.3", | ||
"@bunt/unit": "^0.26.3", | ||
"@bunt/util": "^0.26.3", | ||
"@bunt/assert": "^0.27.0", | ||
"@bunt/async": "^0.27.0", | ||
"@bunt/input": "^0.27.0", | ||
"@bunt/is": "^0.27.0", | ||
"@bunt/unit": "^0.27.0", | ||
"@bunt/util": "^0.27.0", | ||
"@types/busboy": "^1.5.0", | ||
@@ -45,3 +48,3 @@ "busboy": "^1.6.0", | ||
"license": "MIT", | ||
"gitHead": "07d3ee4d12a7ceec0cacec519425a2cfab1f70c4" | ||
"gitHead": "ed8a1abf168ea3ed94209268406d2b8e9834a5a5" | ||
} |
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
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
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
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
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
295765
1619
9
+ Added@bunt/assert@^0.27.0
+ Added@bunt/async@^0.27.0
+ Added@bunt/is@^0.27.0
+ Added@bunt/assert@0.27.1(transitive)
+ Added@bunt/async@0.27.1(transitive)
+ Added@bunt/input@0.27.1(transitive)
+ Added@bunt/is@0.27.1(transitive)
+ Added@bunt/type@0.27.1(transitive)
+ Added@bunt/unit@0.27.1(transitive)
+ Added@bunt/util@0.27.1(transitive)
- Removed@bunt/input@0.26.3(transitive)
- Removed@bunt/unit@0.26.3(transitive)
- Removed@bunt/util@0.26.3(transitive)
Updated@bunt/input@^0.27.0
Updated@bunt/unit@^0.27.0
Updated@bunt/util@^0.27.0