@devvit/server 0.11.17-next-2025-06-05-43928117e.0 → 0.11.17-next-2025-06-05-ff2582b96.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/create-server.d.ts +6 -2
- package/create-server.d.ts.map +1 -1
- package/create-server.js +1 -0
- package/package.json +7 -7
- package/webbit-server.d.ts +0 -4
- package/webbit-server.d.ts.map +0 -1
- package/webbit-server.js +0 -30
package/create-server.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IncomingMessage, Server, ServerOptions, ServerResponse } from 'node:http';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a new Devvit server. This implements the same API as Node.js's `createServer` function,
|
|
4
4
|
* but we do not guarantee that this actually creates an HTTP server of any kind - it may be any
|
|
5
5
|
* kind of server under the hood. However, it will behave like an HTTP server in terms of the API.
|
|
6
6
|
*/
|
|
7
|
-
export declare const createServer: typeof
|
|
7
|
+
export declare const createServer: <Request extends typeof IncomingMessage = typeof IncomingMessage, Response extends typeof ServerResponse = typeof ServerResponse>(optionsOrRequestListener?: ServerOptions<Request, Response> | ((req: InstanceType<Request>, res: InstanceType<Response> & {
|
|
8
|
+
req: InstanceType<Request>;
|
|
9
|
+
}) => any), requestListener?: (req: InstanceType<Request>, res: InstanceType<Response> & {
|
|
10
|
+
req: InstanceType<Request>;
|
|
11
|
+
}) => any) => Server<Request, Response>;
|
|
8
12
|
declare global {
|
|
9
13
|
namespace globalThis {
|
|
10
14
|
var enableWebbitBundlingHack: boolean;
|
package/create-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../src/create-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../src/create-server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAKxF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,SAAS,OAAO,eAAe,GAAG,OAAO,eAAe,EAC/D,QAAQ,SAAS,OAAO,cAAc,GAAG,OAAO,cAAc,EAE9D,2BACI,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,GAChC,CAAC,CACC,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,EAC1B,GAAG,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG;IAAE,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;CAAE,KACzD,GAAG,CAAC,EACb,kBAAkB,CAChB,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,EAC1B,GAAG,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG;IAAE,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;CAAE,KACzD,GAAG,KACP,MAAM,CAAC,OAAO,EAAE,QAAQ,CAM1B,CAAC;AA0CF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU,CAAC;QAEnB,IAAI,wBAAwB,EAAE,OAAO,CAAC;KACvC;CACF"}
|
package/create-server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/server",
|
|
3
|
-
"version": "0.11.17-next-2025-06-05-
|
|
3
|
+
"version": "0.11.17-next-2025-06-05-ff2582b96.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-05-
|
|
27
|
-
"@devvit/public-api": "0.11.17-next-2025-06-05-
|
|
28
|
-
"@devvit/shared-types": "0.11.17-next-2025-06-05-
|
|
26
|
+
"@devvit/protos": "0.11.17-next-2025-06-05-ff2582b96.0",
|
|
27
|
+
"@devvit/public-api": "0.11.17-next-2025-06-05-ff2582b96.0",
|
|
28
|
+
"@devvit/shared-types": "0.11.17-next-2025-06-05-ff2582b96.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@devvit/repo-tools": "0.11.17-next-2025-06-05-
|
|
32
|
-
"@devvit/tsconfig": "0.11.17-next-2025-06-05-
|
|
31
|
+
"@devvit/repo-tools": "0.11.17-next-2025-06-05-ff2582b96.0",
|
|
32
|
+
"@devvit/tsconfig": "0.11.17-next-2025-06-05-ff2582b96.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": "4dd9c7e850fa22f59dd9b0fa2e9753476f0353fc"
|
|
42
42
|
}
|
package/webbit-server.d.ts
DELETED
package/webbit-server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webbit-server.d.ts","sourceRoot":"","sources":["../src/webbit-server.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,oDAAoD,CAAC;AAM5D,wBAAgB,YAAY,IAAI,IAAI,CAInC;AAED,wBAAgB,eAAe,IAAI,YAAY,CAsB9C"}
|
package/webbit-server.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { HttpMethod, WebbitServerDefinition, } from '@devvit/protos/types/devvit/actor/webbit/webbit.js';
|
|
2
|
-
import { Devvit } from '@devvit/public-api';
|
|
3
|
-
import { extendDevvitPrototype } from '@devvit/public-api/devvit/internals/helpers/extendDevvitPrototype.js';
|
|
4
|
-
import { getServerPort } from './get-server-port.js';
|
|
5
|
-
export function webbitEnable() {
|
|
6
|
-
const server = newWebbitServer();
|
|
7
|
-
extendDevvitPrototype('Request', server.Request);
|
|
8
|
-
Devvit.provide(WebbitServerDefinition);
|
|
9
|
-
}
|
|
10
|
-
export function newWebbitServer() {
|
|
11
|
-
return {
|
|
12
|
-
async Request(req, meta) {
|
|
13
|
-
const port = getServerPort();
|
|
14
|
-
// only set the body if the method is not GET or HEAD
|
|
15
|
-
const body = [HttpMethod.GET, HttpMethod.HEAD].includes(req.method) ? null : req.body;
|
|
16
|
-
const rsp = await fetch(new URL(req.path, `http://webbit.local:${port}`), {
|
|
17
|
-
body,
|
|
18
|
-
headers: [
|
|
19
|
-
...Object.entries(req.headers),
|
|
20
|
-
// devvit- headers alway have priority.
|
|
21
|
-
...Object.entries(meta ?? {}).map(([k, v]) => [k, v.values.join()]),
|
|
22
|
-
],
|
|
23
|
-
method: HttpMethod[req.method],
|
|
24
|
-
});
|
|
25
|
-
const headers = {};
|
|
26
|
-
rsp.headers.forEach((v, k) => (headers[k] = v));
|
|
27
|
-
return { body: new Uint8Array(await rsp.arrayBuffer()), headers, statusCode: rsp.status };
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
}
|