@ucdjs-internal/worker-utils
v0.1.0
Published
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href]
Readme
@ucdjs-internal/worker-utils
Shared worker utilities for the UCD.js API and Store workers.
Installation
npm install @ucdjs-internal/worker-utilsUsage
import {
badRequest,
errorHandler,
notFoundHandler,
} from "@ucdjs-internal/worker-utils";
import { Hono } from "hono";
const app = new Hono();
app.get("/hello", (c) => {
const name = c.req.query("name");
if (!name) {
return badRequest(c, { message: "Missing name query parameter" });
}
return c.json({
message: `Hello ${name}!`,
});
});
app.notFound(notFoundHandler);
app.onError(errorHandler);
export default app;Notes
The environment helpers are shared by the API and Store workers.
production resolves to the public ucdjs.dev origins, preview includes preview worker origins, and local or unknown environments fall back to localhost-style defaults.
The CORS setup helpers build on those defaults so each worker does not need to duplicate its own origin lists.
📄 License
Published under MIT License.
