Skip to content
File

Blob: src/cloudflare/internal/br-api.ts

typescript28 lines
1// Copyright (c) 2025 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5interface Fetcher {
6 fetch: typeof fetch;
7}
8 
9export class BrowserRendering {
10 // TODO(soon): Can we use the # syntax here?
11 // eslint-disable-next-line no-restricted-syntax
12 private readonly fetcher: Fetcher;
13 
14 constructor(fetcher: Fetcher) {
15 this.fetcher = fetcher;
16 }
17 
18 async fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
19 return this.fetcher.fetch(input, init);
20 }
21}
22 
23export default function makeBinding(env: {
24 fetcher: Fetcher;
25}): BrowserRendering {
26 return new BrowserRendering(env.fetcher);
27}