0.2.0 • Published 4 years ago

@proc/context-koa v0.2.0

Weekly downloads
6
License
MIT
Repository
-
Last release
4 years ago

Koa Middleware to provide context.

Get a @proc/context object for every request. While this package works standalone, a more complete web server implementation exists as @proc/runtime.

Usage

import Koa from "koa";
import { createContext } from "@proc/context";
import { middleware, getRequestContext } from "@proc/context-koa";

const app = new Koa();
const parentContext = createContext();
app.use(middleware(parentContext));

app.use((ktx, next) => {
  const childContext = getRequestContext(ktx);
  ktx.body = `Child context had id: ${childContext.id}`;
});

app.listen(8080);
0.2.0

4 years ago

0.1.36

5 years ago

0.1.35

5 years ago

0.1.32

5 years ago

0.1.28

5 years ago