Gathering detailed insights and metrics for @visual-thinking/stoker
Gathering detailed insights and metrics for @visual-thinking/stoker
Gathering detailed insights and metrics for @visual-thinking/stoker
Gathering detailed insights and metrics for @visual-thinking/stoker
npm install @visual-thinking/stoker
Typescript
Module System
Node Version
NPM Version
74
Supply Chain
98.6
Quality
86
Maintenance
100
Vulnerability
100
License
TypeScript (99%)
JavaScript (1%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
345 Stars
25 Commits
32 Forks
4 Watchers
2 Branches
4 Contributors
Updated on Jul 27, 2025
Latest Version
2.0.3
Package Id
@visual-thinking/stoker@2.0.3
Unpacked Size
152.32 kB
Size
22.03 kB
File Count
104
NPM Version
11.4.2
Node Version
24.3.0
Published on
Jul 02, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
stoke the flame 🤙🔥
Utilities for hono and @hono/zod-openapi.
To see real world usage of these utilities, checkout the hono-open-api-starter routes example
HTTP status code constants. Provides individual typed / documented exports. Use anywhere you need a status code instead of hard coding raw numbers.
Sourced from http-status-codes | RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), RFC2518 (WebDAV), RFC6585 (Additional HTTP Status Codes), and RFC7538 (Permanent Redirect).
Why not use the
http-status-codes
package directly?http-status-codes
exports enums which do not work well with the@hono/zod-openapi
type system and the built inStatusCode
type fromhono/utils/http-status
.
1import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; 2import * as HttpStatusCodes from "stoker/http-status-codes"; 3 4const app = new OpenAPIHono(); 5 6app.notFound((c) => { 7 return c.json({ 8 message: `Not Found - ${c.req.path}`, 9 }, HttpStatusCodes.NOT_FOUND); 10}); 11 12app.onError((err, c) => { 13 return c.json( 14 { 15 message: err.message, 16 }, 17 HttpStatusCodes.INTERNAL_SERVER_ERROR, 18 ); 19}); 20 21app.openapi( 22 createRoute({ 23 path: "/", 24 tags: ["Index"], 25 description: "Index route", 26 method: "get", 27 responses: { 28 [HttpStatusCodes.OK]: { 29 content: { 30 "application/json": { 31 schema: z.object({ 32 message: z.string(), 33 }), 34 }, 35 }, 36 description: "Index route", 37 }, 38 }, 39 }), 40 (c) => { 41 return c.json({ message: "Hello World" }, HttpStatusCodes.OK); 42 }, 43); 44 45export default app;
HTTP status phrase constants.
1import * as HttpStatusPhrases from "stoker/http-status-phrases"; 2 3console.log(HttpStatusPhrases.NOT_FOUND); // Not Found
A default 404 handler.
1import { Hono } from "hono"; 2import notFound from "stoker/middlewares/not-found"; 3 4const app = new Hono(); 5 6app.notFound(notFound); 7 8export default app;
A default error handler.
1import { Hono } from "hono"; 2import onError from "stoker/middlewares/on-error"; 3 4const app = new Hono(); 5 6app.onError(onError); 7 8export default app;
Serve an svg emoji as a favicon from /favicon.ico
1import { Hono } from "hono"; 2import serveEmojiFavicon from "stoker/middlewares/serve-emoji-favicon"; 3 4const app = new Hono(); 5 6app.use(serveEmojiFavicon("🔥")); 7 8export default app;
A default error hook you can include in your OpenAPIHono instance. Includes the success
status and ZodError
1import { OpenAPIHono } from "@hono/zod-openapi"; 2import defaultHook from "stoker/openapi/default-hook"; 3 4/* 5Any validation errors will respond with status code 422 and body: 6{ 7 success: false, 8 error: {}, // Full Zod Error 9} 10*/ 11const app = new OpenAPIHono({ 12 defaultHook, 13}); 14 15export default app;
Create a content / schema description with a type of application/json
1import { z } from "@hono/zod-openapi"; 2import jsonContent from "stoker/openapi/helpers/json-content"; 3 4const schema = z.object({ 5 message: z.string(), 6}); 7 8/* 9* Equivalent to: 10{ 11 content: { 12 "application/json": { 13 schema, 14 }, 15 }, 16 description: "Retrieve the user", 17} 18*/ 19const response = jsonContent( 20 schema, 21 "Retrieve the message" 22);
Useful for json body schema validators.
Create a content / schema description with a type of application/json
and required set to true
1import { z } from "@hono/zod-openapi"; 2import jsonContentRequired from "stoker/openapi/helpers/json-content-required"; 3 4const schema = z.object({ 5 message: z.string(), 6}); 7 8/* 9* Equivalent to: 10{ 11 content: { 12 "application/json": { 13 schema, 14 }, 15 }, 16 description: "Retrieve the user", 17 required: true 18} 19*/ 20const response = jsonContentRequired( 21 schema, 22 "Retrieve the message" 23);
Peer dependency of
@asteasolutions/zod-to-openapi
WARNING: Not recommended right now, type hints from @hono/zod-openapi are not correct when using this helper. If you don't absolutely need
oneOf
in your specification, use zodor
(anyOf) instead.
Create a json content / schema description where the schema can be oneOf multiple schemas. Useful when you have multiple possible validation response schemas.
1import { z } from "@hono/zod-openapi"; 2import jsonContentOneOf from "stoker/openapi/helpers/json-content-one-of"; 3import createErrorSchema from "stoker/openapi/schemas/create-error-schema"; 4import IdParamsSchema from "stoker/openapi/schemas/id-params"; 5 6const bodySchema = z.object({ 7 name: z.string(), 8}); 9 10/* 11* Equivalent to: 12{ 13 content: { 14 "application/json": { 15 schema: { 16 oneOf: SchemaObject[] 17 }, 18 }, 19 }, 20 description: "Invalid Id params or Invalid Body" 21} 22*/ 23const result = jsonContentOneOf( 24 [createErrorSchema(IdParamsSchema), createErrorSchema(bodySchema)], 25 "Invalid Id params or Invalid Body" 26);
Peer dependency of
@asteasolutions/zod-to-openapi
Used internally by stoker/openapi/helpers/json-content-one-of
but exported here in case you need to access the generated schemas for other use cases.
1import { z } from "@hono/zod-openapi"; 2import oneOf from "stoker/openapi/helpers/one-of"; 3import createErrorSchema from "stoker/openapi/schemas/create-error-schema"; 4import IdParamsSchema from "stoker/openapi/schemas/id-params"; 5 6const bodySchema = z.object({ 7 name: z.string(), 8}); 9 10/* 11* Returns: SchemaObject[] 12*/ 13const result = oneOf([createErrorSchema(IdParamsSchema), createErrorSchema(bodySchema)]);
Commonly used zod schemas for use when creating routes with @hono/zod-openapi
Validate id
in path params as a number.
1import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; 2import * as HttpStatusCodes from "stoker/http-status-codes"; 3import jsonContent from "stoker/openapi/helpers/json-content"; 4import IdParamsSchema from "stoker/openapi/schemas/id-params"; 5 6const app = new OpenAPIHono(); 7 8app.openapi( 9 createRoute({ 10 method: "get", 11 path: "/users/{id}", 12 request: { 13 params: IdParamsSchema, 14 }, 15 responses: { 16 [HttpStatusCodes.OK]: jsonContent( 17 z.object({ 18 id: z.number(), 19 }), 20 "Retrieve the user", 21 ), 22 }, 23 }), 24 (c) => { 25 // id is a valid number 26 const { id } = c.req.valid("param"); 27 return c.json({ 28 id, 29 }, HttpStatusCodes.OK); 30 }, 31); 32 33export default app;
Validate slug
in path params as a slug.
1import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; 2import * as HttpStatusCodes from "stoker/http-status-codes"; 3import jsonContent from "stoker/openapi/helpers/json-content"; 4import SlugParamsSchema from "stoker/openapi/schemas/slug-params"; 5 6const app = new OpenAPIHono(); 7 8app.openapi( 9 createRoute({ 10 method: "get", 11 path: "/posts/{slug}", 12 request: { 13 params: SlugParamsSchema, 14 }, 15 responses: { 16 [HttpStatusCodes.OK]: jsonContent( 17 z.object({ 18 slug: z.string(), 19 }), 20 "Retrieve the post", 21 ), 22 }, 23 }), 24 (c) => { 25 // slug is a valid slug 26 const { slug } = c.req.valid("param"); 27 return c.json({ 28 slug, 29 }, HttpStatusCodes.OK); 30 }, 31); 32 33export default app;
Validate id
in path params as a uuid.
1import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; 2import * as HttpStatusCodes from "stoker/http-status-codes"; 3import jsonContent from "stoker/openapi/helpers/json-content"; 4import IdUUIDParamsSchema from "stoker/openapi/schemas/id-uuid-params"; 5 6const app = new OpenAPIHono(); 7 8app.openapi( 9 createRoute({ 10 method: "get", 11 path: "/users/{id}", 12 request: { 13 params: IdUUIDParamsSchema, 14 }, 15 responses: { 16 [HttpStatusCodes.OK]: jsonContent( 17 z.object({ 18 id: z.uuid(), 19 }), 20 "Retrieve the user", 21 ), 22 }, 23 }), 24 (c) => { 25 // id is a valid uuid 26 const { id } = c.req.valid("param"); 27 return c.json({ 28 id, 29 }, HttpStatusCodes.OK); 30 }, 31); 32 33export default app;
Validate a custom named path param using Zod string validators by calling the function getParamsSchema({ name, validator })
.
Name defaults to id
.
Validator defaults to uuid
and supports type "uuid" | "nanoid" | "cuid" | "cuid2" | "ulid"
.
1import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; 2import * as HttpStatusCodes from "stoker/http-status-codes"; 3import jsonContent from "stoker/openapi/helpers/json-content"; 4import getParamsSchema from "stoker/openapi/schemas/get-params-schema"; 5 6const app = new OpenAPIHono(); 7 8app.openapi( 9 createRoute({ 10 method: "get", 11 path: "/users/{userId}", 12 request: { 13 params: getParamsSchema({ 14 name: "userId", 15 validator: "nanoid", 16 }), 17 }, 18 responses: { 19 [HttpStatusCodes.OK]: jsonContent( 20 z.object({ 21 userId: z.nanoid(), 22 }), 23 "Retrieve the user", 24 ), 25 }, 26 }), 27 (c) => { 28 // userId is a valid nanoid 29 const { userId } = c.req.valid("param"); 30 return c.json({ 31 userId, 32 }, HttpStatusCodes.OK); 33 }, 34); 35 36export default app;
Create an object schema with a message string property. Useful for error messages.
1import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; 2import * as HttpStatusCodes from "stoker/http-status-codes"; 3import * as HttpStatusPhrases from "stoker/http-status-phrases"; 4import jsonContent from "stoker/openapi/helpers/json-content"; 5import createMessageObjectSchema from "stoker/openapi/schemas/create-message-object"; 6import IdParamsSchema from "stoker/openapi/schemas/id-params"; 7 8const app = new OpenAPIHono(); 9 10app.openapi( 11 createRoute({ 12 method: "get", 13 path: "/some-thing-that-might-not-be-found", 14 responses: { 15 [HttpStatusCodes.NOT_FOUND]: jsonContent( 16 createMessageObjectSchema(HttpStatusPhrases.NOT_FOUND), 17 HttpStatusPhrases.NOT_FOUND, 18 ), 19 }, 20 }), 21 (c) => { 22 return c.json({ 23 message: HttpStatusPhrases.NOT_FOUND, 24 }, HttpStatusCodes.NOT_FOUND); 25 }, 26); 27 28export default app;
Create an example error schema with zod error / validation messages based on given schema.
1import { createRoute, z } from "@hono/zod-openapi";
2import * as HttpStatusCodes from "stoker/http-status-codes";
3import jsonContent from "stoker/openapi/helpers/json-content";
4import createErrorSchema from "stoker/openapi/schemas/create-error-schema";
5
6const TaskSchema = z.object({
7 name: z.string(),
8 completed: z.boolean().default(false),
9});
10
11export const createTask = createRoute({
12 method: "post",
13 path: "/task",
14 request: {
15 body: jsonContent(TaskSchema, "The Task"),
16 },
17 responses: {
18 // ... OK response here
19 [HttpStatusCodes.UNPROCESSABLE_ENTITY]: jsonContent(
20 // Creates example schema with validation messages for name / completed
21 createErrorSchema(TaskSchema),
22 "Invalid task",
23 ),
24 },
25});
Project bootstrapped with antfu/starter-ts
No vulnerabilities found.