You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# node-execution-context
2
2
A straightforward library that provides a persistent process-level context wrapper using node "async_hooks" feature.
3
-
This library will try to use by default [`AsyncLocalStorage`](https://nodejs.org/api/async_hooks.html#async_hooks_class_asynclocalstorage) implementation based if current node version supports it, otherwise it will fallback to raw [`async_hooks`](https://nodejs.org/api/async_hooks.html) implementation for lower versions which mimics this behaviour.
3
+
This library will try to use by default [`AsyncLocalStorage`](https://nodejs.org/api/async_hooks.html#async_hooks_class_asynclocalstorage) implementation based if current node version supports it, otherwise it will fallback to raw [`async_hooks`](https://nodejs.org/api/async_hooks.html) implementation for lower versions which mimics this behaviour.
4
4
5
5
## Installation
6
6
@@ -10,7 +10,7 @@ npm i node-execution-context
10
10
11
11
## Getting started
12
12
13
-
Let't start with creating the context initialisation point of our app, well take an simples express app for this example
13
+
Let's start with creating the context initialisation point of our app, we will take a simple express app for this example
14
14
15
15
```js
16
16
// main.js
@@ -32,7 +32,7 @@ app.listen(port);
32
32
33
33
```
34
34
35
-
This will expose any point of your code form this point that handles that request.
35
+
This will expose any point of your code form this point that handles that request.
// This will return the reference number set by out ContextMiddleware (generated by Math.random())
49
49
const { reference } =Context.get();
50
-
50
+
51
51
logger.info('Created user for reference: ', reference);
52
-
52
+
53
53
returnawaitmongo.create('user', user);
54
54
}
55
55
}
@@ -66,7 +66,7 @@ The context will be exposed to all callbacks and promise chains triggered from t
66
66
67
67
Gets the current asynchronous execution context.
68
68
69
-
> The `get` result is returned by `reference` meaning if you wish any immutability applied, it will have to be manually applied.
69
+
> The `get` result is returned by `reference` meaning if you wish any immutability applied, it will have to be manually applied.
70
70
71
71
> This API may throw CONTEXT_DOES_NOT_EXIST error if accessed without initializing the context properly.
72
72
@@ -81,7 +81,7 @@ Sets the current asynchronous execution context to given value.
81
81
Creates a given context for the current asynchronous execution.
82
82
It is recommended to use the `run` method. This method should be used in special cases in which the `run` method cannot be used directly.
83
83
84
-
> Note that if this method will be called not within a AsyncResource context, it will effect current execution context and should be used with caution.
84
+
> Note that if this method will be called not within a AsyncResource context, it will effect current execution context and should be used with caution.
0 commit comments