@devvit/server 0.11.17-next-2025-06-11-9c40662f8.0 → 0.11.17-next-2025-06-12-5604c773b.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/context.d.ts +1 -7
- package/context.d.ts.map +1 -1
- package/context.js +15 -1
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +1 -2
- package/package.json +7 -7
package/context.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import type { RequestContext } from './request-context.js';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the current RequestContext. This is set by the server when handling a request. If there is no
|
|
4
|
-
* context, this will throw an error.
|
|
5
|
-
* @returns The current RequestContext.
|
|
6
|
-
* @throws Error Will throw an error if there is no context.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getContext(): RequestContext;
|
|
9
2
|
/**
|
|
10
3
|
* Runs an async callback with the given RequestContext. Code in the callback can use
|
|
11
4
|
* `getContext()` to get the context.
|
|
@@ -14,4 +7,5 @@ export declare function getContext(): RequestContext;
|
|
|
14
7
|
* @param callback The callback to run
|
|
15
8
|
*/
|
|
16
9
|
export declare function runWithContext<T>(context: RequestContext, callback: () => Promise<T>): Promise<T>;
|
|
10
|
+
export declare const context: import("@devvit/public-api").BaseContext;
|
|
17
11
|
//# sourceMappingURL=context.d.ts.map
|
package/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAoB3D;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED,eAAO,MAAM,OAAO,0CAalB,CAAC"}
|
package/context.js
CHANGED
|
@@ -6,7 +6,7 @@ const requestContextStorage = new AsyncLocalStorage();
|
|
|
6
6
|
* @returns The current RequestContext.
|
|
7
7
|
* @throws Error Will throw an error if there is no context.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
function getContext() {
|
|
10
10
|
const ctx = requestContextStorage.getStore();
|
|
11
11
|
if (!ctx) {
|
|
12
12
|
throw new Error('No context found. Are you calling `createServer` Is this code running as part of a server request?');
|
|
@@ -23,3 +23,17 @@ export function getContext() {
|
|
|
23
23
|
export async function runWithContext(context, callback) {
|
|
24
24
|
return requestContextStorage.run(context, callback);
|
|
25
25
|
}
|
|
26
|
+
export const context = new Proxy({}, {
|
|
27
|
+
get: (_target, prop) => {
|
|
28
|
+
const context = getContext();
|
|
29
|
+
return context[prop];
|
|
30
|
+
},
|
|
31
|
+
// The following two methods set up the Proxy to behave like a normal object when iterating over keys or
|
|
32
|
+
// checking if a property exists. (This helps ensure tests pass too.)
|
|
33
|
+
ownKeys() {
|
|
34
|
+
return Object.keys(getContext());
|
|
35
|
+
},
|
|
36
|
+
getOwnPropertyDescriptor(_target, key) {
|
|
37
|
+
return { enumerable: true, configurable: true, value: getContext()[key] };
|
|
38
|
+
},
|
|
39
|
+
});
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { context } from './context.js';
|
|
2
2
|
export { createServer } from './create-server.js';
|
|
3
3
|
export { defineConfig } from './define-config.js';
|
|
4
4
|
export { getServerPort } from './get-server-port.js';
|
|
5
|
-
export { RequestContext
|
|
5
|
+
export type { RequestContext } from './request-context.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { context } from './context.js';
|
|
2
2
|
export { createServer } from './create-server.js';
|
|
3
3
|
export { defineConfig } from './define-config.js';
|
|
4
4
|
export { getServerPort } from './get-server-port.js';
|
|
5
|
-
export { RequestContext, setRequestContext } from './request-context.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/server",
|
|
3
|
-
"version": "0.11.17-next-2025-06-
|
|
3
|
+
"version": "0.11.17-next-2025-06-12-5604c773b.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
},
|
|
24
24
|
"types": "./index.d.ts",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@devvit/protos": "0.11.17-next-2025-06-
|
|
27
|
-
"@devvit/public-api": "0.11.17-next-2025-06-
|
|
28
|
-
"@devvit/shared-types": "0.11.17-next-2025-06-
|
|
26
|
+
"@devvit/protos": "0.11.17-next-2025-06-12-5604c773b.0",
|
|
27
|
+
"@devvit/public-api": "0.11.17-next-2025-06-12-5604c773b.0",
|
|
28
|
+
"@devvit/shared-types": "0.11.17-next-2025-06-12-5604c773b.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@devvit/repo-tools": "0.11.17-next-2025-06-
|
|
32
|
-
"@devvit/tsconfig": "0.11.17-next-2025-06-
|
|
31
|
+
"@devvit/repo-tools": "0.11.17-next-2025-06-12-5604c773b.0",
|
|
32
|
+
"@devvit/tsconfig": "0.11.17-next-2025-06-12-5604c773b.0",
|
|
33
33
|
"eslint": "9.11.1",
|
|
34
34
|
"typescript": "5.8.3",
|
|
35
35
|
"vitest": "1.6.1"
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"directory": "dist"
|
|
39
39
|
},
|
|
40
40
|
"source": "./src/index.ts",
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "638acc6a7d1c823995eda60746441a19aa42fe41"
|
|
42
42
|
}
|