Skip to content
On this page

Welcome to Wooks!

WARNING

Wooks is an evolving framework. It's fully functional and ready for immediate use, but please note that certain APIs may be fine-tuned as we proceed.

You're about to discover the principles and concepts that make up the backbone of Wooks, without getting into the nitty-gritty of specific implementations or event types.

An Intro to Wooks

Welcome to Wooks! This innovative event processing framework handles all the key steps of event processing workflows: Routing, Contexting, and Responding.

Initially, Wooks was born to manage HTTP events, but now it also supports building efficient command-line interfaces (CLIs). And the best part? We're planning on introducing even more event types soon!

The essence of Wooks lies in its core principles:

  • Every event can be routed to its ideal handler.
  • Each event comes with its unique context (state).
  • The event context (state) resides in a special object that is accessible to handlers through composables (hooks).
  • Handlers can return data to be interpreted as a Response.

TIP

The inspiration behind composables comes from the Vue 3 Composition API. It also bears similarities to React's hooks.

Event Routing

Wooks leverages the power of @prostojs/router for swift and reliable routing. This versatile URI router supports parameters and wildcards and competes with find-my-way in terms of speed. Check out the comparison benchmarks with express, find-my-way, and radix3.

Here is a snapshot of the performance:

Details
Test NameExpress avg op/msFindMyWay avg op/msProstoRouter avg op/msRadix3 avg op/ms
Short static1 7927 0706 91210 326
Static with same radix1 3884 6628 53714 058
Dynamic route7391 7681 888959
Mixed static dynamic6853 1013 470988
Long static6372 1748 93414 000
Wildcard4862 0812 0651 019
All together6632 3282 8931 549

Event Context

Once the router locates an event handler, both the handler and route parameters are handed over to the Wooks event processing loop. Here, a new event context is born with pre-filled URI parameters.

An event context includes:

  • type: Aligns with the event source (HTTP, CLI, etc.)
  • params: Parameters parsed by the router during the lookup.
  • custom data: Additional data to be parsed, fetched, and cached (like the parsedBody of an HTTP event)

The base API for the event context is in the @wooksjs/event-core library.

Event-specific libraries offer wrappers around event-core for accurate typing and event-specific composables. These libraries all have the event- prefix, such as @wooksjs/event-http, @wooksjs/event-cli, and so on.

Response

While Wooks doesn't offer a generic response handling mechanism, each event-specific wrapper library takes care of response management. For example, @wooksjs/event-http includes a responder that can manage responses based on the event context and handler's returned values.

Ready to Explore More?

Currently, Wooks offers two libraries for creating event processing applications:

  1. @wooksjs/event-http — Perfect for handling HTTP event processing and a worthy alternative to well-known web application frameworks. Dive deeper here.
  2. @wooksjs/event-cli — Manages command-line input processing and command routing. Find out more here.

In the subsequent sections of this documentation, we'll show you detailed examples of how to make the most of this dynamic framework. Stay tuned!

Released under the MIT License.