@cloudwerk/core
v0.15.3
Published
Routing, middleware, config for Cloudwerk
Readme
@cloudwerk/core
Core routing, middleware, and configuration for Cloudwerk - a full-stack framework for Cloudflare Workers.
Installation
npm install @cloudwerk/coreEntry Points
This package provides two entry points optimized for different use cases:
@cloudwerk/core/runtime
Runtime-only exports for Cloudflare Workers. Excludes build-time dependencies to minimize bundle size.
import {
// Response helpers
json, created, noContent, redirect, html, text,
notFoundResponse, badRequest, unauthorized, forbidden,
// Context and middleware
getContext, createMiddlewareAdapter,
// Errors
NotFoundError, RedirectError, notFound,
// Types
type CloudwerkHandler, type CloudwerkHandlerContext,
type PageProps, type LayoutProps, type LoaderArgs
} from '@cloudwerk/core/runtime'@cloudwerk/core/build
Build-time exports for CLI and tooling. Includes filesystem dependencies (fast-glob, esbuild).
import {
// Route compilation
buildRouteManifest, scanRoutes, compileRoute,
// Configuration
loadConfig, defineConfig, DEFAULT_CONFIG,
// Validation
validateManifest, validateRoute,
// Types
type RouteManifest, type CloudwerkConfig
} from '@cloudwerk/core/build'Basic Usage
// app/routes/users/[id]/route.ts
import { json, notFoundResponse } from '@cloudwerk/core/runtime'
import type { CloudwerkHandler } from '@cloudwerk/core/runtime'
export const GET: CloudwerkHandler = async (request, { params }) => {
const user = await getUser(params.id)
if (!user) return notFoundResponse()
return json(user)
}Documentation
For full documentation, visit: https://github.com/squirrelsoft-dev/cloudwerk
Part of Cloudwerk
This package is part of the Cloudwerk monorepo.
