Skip to content

Latest commit

 

History

214 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stratal

Stratal

A modular framework for building Cloudflare Workers with dependency injection, OpenAPI documentation, queues, cron jobs, and more.

npm version CI License: MIT OpenSSF Scorecard Known Vulnerabilities npm downloads TypeScript Bundle size PRs Welcome GitHub stars

Features

  • Dependency Injection — Two-tier DI container (global + request-scoped) with decorator-based injection
  • Modular Architecture — NestJS-style modules with lifecycle hooks, dynamic configuration, and lazy loading
  • Routing — Convention-based RESTful controllers on Hono, plus explicit method decorators, named routes, versioning, and domain routing
  • OpenAPI Documentation — Define Zod schemas once and get an OpenAPI 3.0 spec with Swagger UI
  • Queues and Cron — Typed Cloudflare Queue consumers with message-type filtering, and scheduled jobs via cron triggers
  • Events — In-process and queue-backed event listeners with @Listener / @On
  • WebSockets and SSE — Gateway classes with @OnMessage / @OnClose / @OnError, and server-sent event streams
  • Caching — KV-backed cache with optional isolate-level L1 tiering, plus @Cacheable / @PurgesCache response caching on the Workers Cache API
  • Rate Limiting — Declarative @RateLimit with named limiters
  • Storage — Cloudflare R2 file storage with presigned URLs and resumable multipart uploads (TUS-compatible)
  • Email — SMTP provider with React Email template support and queued delivery
  • i18n — Type-safe internationalization with locale detection from request headers
  • Configuration — Namespaced, validated config with typed dot-path access
  • Guards and Middleware — Route protection and per-module middleware configuration
  • Seeders — Ordered database seeders with db:seed commands
  • Quarry CLI — Built-in commands for routes, queues, events, i18n and schedules — and mcp:serve, which exposes your API routes to an AI agent as MCP tools

Used in production

NounStudy        Admissio

Requirements

  • Node.js ≥ 22
  • A Cloudflare Workers project

Getting started

Scaffold a new project from an official template:

npm create stratal my-app
# or
yarn create stratal my-app
# or
pnpm create stratal my-app

Or add Stratal to an existing project:

npm install stratal
# or
yarn add stratal

Packages

Package npm Description
stratal npm Core framework — modules, DI, routing, OpenAPI, queues, cron, events, cache, storage, email, i18n, Quarry CLI
@stratal/framework npm Auth (Better Auth), database ORM (ZenStack), access control, guards, factories
@stratal/testing npm Testing utilities, HTTP/WebSocket/SSE/CLI clients, mocks, Vitest plugin
@stratal/inertia npm Inertia.js v3 server adapter — React SSR on Workers, SEO, partial reloads
@stratal/inertia-modal npm Backend-driven modal pages built on @stratal/inertia
@stratal/feature-flags npm Cloudflare Flagship feature flags with Inertia sharing and React hooks

All packages are versioned together — one release bumps them all.

AI Agent Skills

Stratal provides Agent Skills for AI coding assistants like Claude Code and Cursor. Install to give your AI agent knowledge of Stratal patterns, conventions, and APIs:

npx skills add strataljs/stratal
Skill Description
stratal Build Cloudflare Workers apps with the Stratal framework — modules, DI, controllers, routing, OpenAPI, queues, cron, events, seeders, CLI, auth, database, access control, testing, and more

Quick Start

Define a module with a controller and wire it up as a Cloudflare Worker:

import { Stratal } from 'stratal'
import { Module } from 'stratal/module'
import { Controller, Route, type RouterContext } from 'stratal/router'
import { object, string } from 'zod/mini'

// Define a controller
@Controller('/api/greetings')
class GreetingsController {
  @Route({
    summary: 'Say hello',
    response: object({ message: string() }),
  })
  async index(ctx: RouterContext) {
    return ctx.json({ message: 'Hello from Stratal!' })
  }
}

// Create the root module
@Module({
  controllers: [GreetingsController],
})
class AppModule {}

// Worker entry point
export default new Stratal({ module: AppModule })

@Route() maps method names to HTTP verbs by convention — indexGET /api/greetings, showGET /api/greetings/:id, createPOST (201), updatePUT, patchPATCH, destroyDELETE. Use @Get(), @Post() and friends when the convention doesn't fit.

Documentation

Full guides and examples are available at stratal.dev. API reference lives at api-reference.stratal.dev. Runnable examples live at strataljs/examples.

Support the project

If Stratal is useful to you, star the repository — it is the simplest way to help others find it.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Maintainer

Built and maintained by Temitayo Fadojutimi@adesege_.

License

MIT

About

A modular framework for building Cloudflare Workers with dependency injection, OpenAPI documentation, queues, cron jobs, and more.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

14 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages