@devvit/server 0.11.17-next-2025-06-05-61fd8e75f.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.
@@ -1,10 +1,14 @@
1
- import { createServer as nodeCreateServer } from 'node:http';
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 nodeCreateServer;
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;
@@ -1 +1 @@
1
- {"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../src/create-server.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7D;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,gBAYjC,CAAC;AAuCF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU,CAAC;QAEnB,IAAI,wBAAwB,EAAE,OAAO,CAAC;KACvC;CACF"}
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
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import { createServer as nodeCreateServer } from 'node:http';
2
3
  import { runWithContext } from './context.js';
3
4
  import { RequestContext } 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-05-61fd8e75f.0",
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-61fd8e75f.0",
27
- "@devvit/public-api": "0.11.17-next-2025-06-05-61fd8e75f.0",
28
- "@devvit/shared-types": "0.11.17-next-2025-06-05-61fd8e75f.0"
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-61fd8e75f.0",
32
- "@devvit/tsconfig": "0.11.17-next-2025-06-05-61fd8e75f.0",
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": "2ae004f9ec8a91646f4d173b7b4dbd2d4e216172"
41
+ "gitHead": "4dd9c7e850fa22f59dd9b0fa2e9753476f0353fc"
42
42
  }
@@ -1,4 +0,0 @@
1
- import { type WebbitServer } from '@devvit/protos/types/devvit/actor/webbit/webbit.js';
2
- export declare function webbitEnable(): void;
3
- export declare function newWebbitServer(): WebbitServer;
4
- //# sourceMappingURL=webbit-server.d.ts.map
@@ -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
- }