text-encode-transform

This module is only available to use in your EdgeWorker code bundles when using the responseProvider event handler.

Exports implementations of TextEncoderStream and TextDecoderStream, as described in https://encoding.spec.whatwg.org/.

import { httpRequest } from 'http-request';
import { createResponse } from 'create-response';
import { TextEncoderStream, TextDecoderStream } from 'text-encode-transform';
export function responseProvider (request) {
  return httpRequest(`${request.scheme}://${request.host}${request.url}`).then(response => {
    return createResponse(
      response.status,
      response.headers,
      response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new TextEncoderStream())
    );
  });
}