@travetto/context 2.2.4 → 3.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,7 +61,3 @@ export class SystemInitiatedContext {
61
61
  }
62
62
  }
63
63
  ```
64
-
65
- ## Extension - Rest
66
-
67
- Within the [RESTful API](https://github.com/travetto/travetto/tree/main/module/rest#readme "Declarative api for RESTful APIs with support for the dependency injection module.") module, it can be challenging to share context across the various layers that may be touched by a request. This module provides [AsyncContextInterceptor](https://github.com/travetto/travetto/tree/main/module/context/src/extension/rest.interceptor.ts#L17) to create a data store that will be private to an individual request. This is used by [Rest Auth](https://github.com/travetto/travetto/tree/main/module/auth-rest#readme "Rest authentication integration support for the travetto framework") to store authenticated user information for built-in authorization and permission validation.
package/index.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export * from './src/service';
2
- export * from './src/decorator';
3
- // Named export needed for proxying
4
- export { AsyncContextInterceptor } from './src/extension/rest.interceptor';
2
+ export * from './src/decorator';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@travetto/context",
3
3
  "displayName": "Async Context",
4
- "version": "2.2.4",
4
+ "version": "3.0.0-rc.0",
5
5
  "description": "Async-aware state management, maintaining context across asynchronous calls.",
6
6
  "keywords": [
7
7
  "async-hooks",
@@ -27,10 +27,7 @@
27
27
  "directory": "module/context"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/di": "^2.2.3"
31
- },
32
- "optionalPeerDependencies": {
33
- "@travetto/rest": "^2.2.4"
30
+ "@travetto/di": "^3.0.0-rc.0"
34
31
  },
35
32
  "publishConfig": {
36
33
  "access": "public"
@@ -1,34 +0,0 @@
1
- // @file-if @travetto/rest
2
- import { GetCacheInterceptor, RestInterceptor, Request, Response, RouteConfig } from '@travetto/rest';
3
- import { Injectable, Inject } from '@travetto/di';
4
- import { Config } from '@travetto/config';
5
-
6
- import { AsyncContext } from '../service';
7
-
8
- @Config('rest.context')
9
- class RestAsyncContext {
10
- disabled = false;
11
- }
12
-
13
- /**
14
- * Enables access to contextual data when running in a rest application
15
- */
16
- @Injectable()
17
- export class AsyncContextInterceptor implements RestInterceptor {
18
-
19
- after = [GetCacheInterceptor];
20
-
21
- @Inject()
22
- context: AsyncContext;
23
-
24
- @Inject()
25
- config: RestAsyncContext;
26
-
27
- applies(route: RouteConfig): boolean {
28
- return !this.config.disabled;
29
- }
30
-
31
- intercept(req: Request, res: Response, next: () => Promise<void>): Promise<void> {
32
- return this.context.run(next);
33
- }
34
- }