@sylphx/lens-server 4.0.0 → 4.1.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 +76 -160
- package/dist/index.d.ts +138 -237
- package/dist/index.js +178 -313
- package/package.json +2 -2
- package/src/e2e/server.test.ts +12 -12
- package/src/handlers/http.test.ts +2 -2
- package/src/handlers/index.ts +3 -20
- package/src/handlers/ws.test.ts +3 -3
- package/src/index.ts +25 -41
- package/src/server/create.test.ts +34 -34
- package/src/server/create.ts +143 -14
- package/src/server/types.ts +34 -8
package/src/server/types.ts
CHANGED
|
@@ -196,19 +196,45 @@ export interface WebSocketLike {
|
|
|
196
196
|
// =============================================================================
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
|
-
* Lens server interface -
|
|
199
|
+
* Lens server interface - Callable HTTP handler with executor methods
|
|
200
200
|
*
|
|
201
|
-
* The
|
|
202
|
-
* Runtime concerns (connections, transport, protocol) are handled by adapters/handlers.
|
|
201
|
+
* The app itself is a fetch handler. Just pass it directly to your runtime.
|
|
203
202
|
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const app = createApp({ router, context: () => ({}) })
|
|
207
206
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
207
|
+
* // Bun - app is directly usable as handler
|
|
208
|
+
* Bun.serve(app)
|
|
209
|
+
*
|
|
210
|
+
* // Or with explicit fetch
|
|
211
|
+
* Bun.serve({ fetch: app.fetch })
|
|
212
|
+
*
|
|
213
|
+
* // Deno
|
|
214
|
+
* Deno.serve(app)
|
|
215
|
+
*
|
|
216
|
+
* // Cloudflare Workers
|
|
217
|
+
* export default app
|
|
218
|
+
* ```
|
|
210
219
|
*/
|
|
211
220
|
export interface LensServer {
|
|
221
|
+
/**
|
|
222
|
+
* Call the app directly as a fetch handler.
|
|
223
|
+
* This makes the app callable: `app(request)` or `Bun.serve(app)`
|
|
224
|
+
*/
|
|
225
|
+
(request: Request): Promise<Response>;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* HTTP fetch handler - Web standard Request/Response.
|
|
229
|
+
* Same as calling app directly: `app.fetch(req)` === `app(req)`
|
|
230
|
+
*
|
|
231
|
+
* Endpoints:
|
|
232
|
+
* - POST / → Execute operations
|
|
233
|
+
* - GET /__lens/metadata → Server metadata
|
|
234
|
+
* - GET /__lens/health → Health check
|
|
235
|
+
*/
|
|
236
|
+
fetch: (request: Request) => Promise<Response>;
|
|
237
|
+
|
|
212
238
|
/** Get server metadata for transport handshake */
|
|
213
239
|
getMetadata(): ServerMetadata;
|
|
214
240
|
|