Skip to content

Commit

Permalink
Add README
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed Dec 25, 2023
1 parent a7f8015 commit e322267
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 15 additions & 1 deletion packages/context/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Context

**WIP**: This package is still a work in progress.
## About

This package contains code for the global context used on the API side of a
Redwood application. It's automatically available in services, auth functions
and custom functions.

## Serveful environments

In serverful environments with Fastify the global context is injected by a
Fastify `onRequest` hook.

## Serverless environments

Babel is used to automatically wrap functions with code that makes the context
available.
4 changes: 3 additions & 1 deletion packages/context/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import type { GlobalContext } from './context'
let CONTEXT_STORAGE: AsyncLocalStorage<Map<string, GlobalContext>>

/**
* This returns a AsyncLocalStorage instance, not the actual store
* This returns a AsyncLocalStorage instance, not the actual store.
* Should not be used by Redwood apps directly. The framework handles
* this.
*/
export const getAsyncStoreInstance = () => {
if (!CONTEXT_STORAGE) {
Expand Down

0 comments on commit e322267

Please sign in to comment.