@busy-hour/blaze
Advanced tools
Comparing version 3.3.2 to 3.3.3
@@ -5,2 +5,9 @@ # Changelog | ||
## [3.3.3](https://github.com/Busy-Hour-Studio/blaze/compare/v3.3.2...v3.3.3) (2024-07-12) | ||
### Bug Fixes | ||
* openapi params ([bd02056](https://github.com/Busy-Hour-Studio/blaze/commit/bd02056ea4593e4133ed97cba4dc80e551d07d5e)) | ||
## [3.3.2](https://github.com/Busy-Hour-Studio/blaze/compare/v3.3.1...v3.3.2) (2024-06-29) | ||
@@ -7,0 +14,0 @@ |
@@ -46,6 +46,3 @@ "use strict"; | ||
const methodMiddlewares = route.middlewares.filter((middleware) => middleware[0] === method).map((middleware) => middleware[1]); | ||
const newRoute = { | ||
...route, | ||
method: method.toLowerCase() | ||
}; | ||
const newRoute = (0, import_router.createOpenApiRouter)(route); | ||
if (allMiddlewares.length) { | ||
@@ -114,3 +111,3 @@ this.use(...allMiddlewares); | ||
} | ||
const docPath = path.replaceAll(/:([^/]+)/g, "{$1}"); | ||
const docPath = (0, import_router.fixOpenApiPath)(path); | ||
app.openAPIRegistry.definitions.forEach((def) => { | ||
@@ -117,0 +114,0 @@ (0, import_router.assignOpenAPIRegistry)(this, docPath, def); |
@@ -21,3 +21,5 @@ "use strict"; | ||
__export(router_exports, { | ||
assignOpenAPIRegistry: () => assignOpenAPIRegistry | ||
assignOpenAPIRegistry: () => assignOpenAPIRegistry, | ||
createOpenApiRouter: () => createOpenApiRouter, | ||
fixOpenApiPath: () => fixOpenApiPath | ||
}); | ||
@@ -62,5 +64,18 @@ module.exports = __toCommonJS(router_exports); | ||
} | ||
function fixOpenApiPath(path) { | ||
return path.replaceAll(/:([^/]+)/g, "{$1}"); | ||
} | ||
function createOpenApiRouter(route) { | ||
const method = route.method === "ALL" ? "POST" : route.method; | ||
return { | ||
...route, | ||
path: fixOpenApiPath(route.path), | ||
method: method.toLowerCase() | ||
}; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
assignOpenAPIRegistry | ||
assignOpenAPIRegistry, | ||
createOpenApiRouter, | ||
fixOpenApiPath | ||
}); |
@@ -7,3 +7,7 @@ // src/router/BlazeRouter.ts | ||
import { ExternalModule } from "../utils/constant.js"; | ||
import { assignOpenAPIRegistry } from "../utils/helper/router.js"; | ||
import { | ||
assignOpenAPIRegistry, | ||
createOpenApiRouter, | ||
fixOpenApiPath | ||
} from "../utils/helper/router.js"; | ||
var BlazeRouter = class _BlazeRouter extends Hono { | ||
@@ -25,6 +29,3 @@ openAPIRegistry; | ||
const methodMiddlewares = route.middlewares.filter((middleware) => middleware[0] === method).map((middleware) => middleware[1]); | ||
const newRoute = { | ||
...route, | ||
method: method.toLowerCase() | ||
}; | ||
const newRoute = createOpenApiRouter(route); | ||
if (allMiddlewares.length) { | ||
@@ -93,3 +94,3 @@ this.use(...allMiddlewares); | ||
} | ||
const docPath = path.replaceAll(/:([^/]+)/g, "{$1}"); | ||
const docPath = fixOpenApiPath(path); | ||
app.openAPIRegistry.definitions.forEach((def) => { | ||
@@ -96,0 +97,0 @@ assignOpenAPIRegistry(this, docPath, def); |
@@ -39,4 +39,17 @@ // src/utils/helper/router.ts | ||
} | ||
function fixOpenApiPath(path) { | ||
return path.replaceAll(/:([^/]+)/g, "{$1}"); | ||
} | ||
function createOpenApiRouter(route) { | ||
const method = route.method === "ALL" ? "POST" : route.method; | ||
return { | ||
...route, | ||
path: fixOpenApiPath(route.path), | ||
method: method.toLowerCase() | ||
}; | ||
} | ||
export { | ||
assignOpenAPIRegistry | ||
assignOpenAPIRegistry, | ||
createOpenApiRouter, | ||
fixOpenApiPath | ||
}; |
@@ -17,3 +17,3 @@ import type { OpenAPIRegistry, OpenApiGeneratorV3, OpenApiGeneratorV31 } from '@asteasolutions/zod-to-openapi'; | ||
doc31(path: string, config: OpenAPIObjectConfig): void; | ||
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app?: BlazeRouter<SubEnv, SubSchema, SubBasePath> | undefined): BlazeRouter<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath>; | ||
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app?: Hono<SubEnv, SubSchema, SubBasePath> | BlazeRouter<SubEnv, SubSchema, SubBasePath>): BlazeRouter<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath>; | ||
} |
@@ -6,3 +6,3 @@ import type { StatusCode } from 'hono/utils/http-status'; | ||
export declare function extractRestParams(params: RestParam): readonly [Method | null, string]; | ||
export declare function getRouteHandler(router: BlazeRouter, method: Method | null): import("hono/types").MiddlewareHandlerInterface<import("hono").Env, {}, "/">; | ||
export declare function getRouteHandler(router: BlazeRouter, method: Method | null): import("hono/types").HandlerInterface<import("hono").Env, "all", {}, "/"> | import("hono/types").MiddlewareHandlerInterface<import("hono").Env, {}, "/">; | ||
export declare function getRestResponse(options: Omit<RestResponseHandlerOption, 'honoCtx'>): readonly [ | ||
@@ -13,3 +13,8 @@ never, | ||
]; | ||
export declare function handleRestError(options: RestErrorHandlerOption): Response & import("hono").TypedResponse<never, 500 | 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | -1, "json">; | ||
export declare function handleRestResponse(options: RestResponseHandlerOption): Response | Promise<Response>; | ||
export declare function handleRestError(options: RestErrorHandlerOption): Response & import("hono").TypedResponse<{ | ||
name: string; | ||
message: string; | ||
stack?: string | undefined; | ||
cause?: undefined; | ||
}, 500 | 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | -1, "json">; | ||
export declare function handleRestResponse(options: RestResponseHandlerOption): Response; |
@@ -1,4 +0,5 @@ | ||
import type { OpenAPIDefinitions } from '@asteasolutions/zod-to-openapi/dist/openapi-registry'; | ||
import type { OpenAPIDefinitions, RouteConfig } from '@asteasolutions/zod-to-openapi/dist/openapi-registry'; | ||
import type { Env, Schema } from 'hono'; | ||
import type { BlazeRouter } from '../../router'; | ||
import type { BlazeOpenAPIOption } from '../../types/router'; | ||
export declare function assignOpenAPIRegistry<E extends Env = Env, S extends Schema = NonNullable<unknown>, BasePath extends string = '/'>(router: BlazeRouter<E, S, BasePath>, docPath: string, def: OpenAPIDefinitions): void | import("zod").ZodTypeAny | { | ||
@@ -10,1 +11,3 @@ name: string; | ||
}; | ||
export declare function fixOpenApiPath(path: string): string; | ||
export declare function createOpenApiRouter(route: BlazeOpenAPIOption): RouteConfig; |
@@ -7,6 +7,6 @@ { | ||
"type": "module", | ||
"version": "3.3.2", | ||
"version": "3.3.3", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@asteasolutions/zod-to-openapi": "^6.3.1", | ||
"@asteasolutions/zod-to-openapi": "^7.1.1", | ||
"@commitlint/cli": "^17.8.1", | ||
@@ -39,3 +39,3 @@ "@commitlint/config-conventional": "^17.8.1", | ||
"dependencies": { | ||
"hono": "^4.0.5", | ||
"hono": "^4.4.9", | ||
"zod": "^3.22.4" | ||
@@ -42,0 +42,0 @@ }, |
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
230615
5982
10
+ Addedhono@4.6.9(transitive)
- Removedhono@4.6.10(transitive)
Updatedhono@^4.4.9