________ _____ ___ __/______________ ________ ________________ ______ __________ /______ ________ __ / __ ___/_ __ `/__ __ \__ ___/___ __ \_ __ \__ ___/_ __/_ _ \__ ___/ _ / _ / / /_/ / _ / / /_(__ ) __ /_/ // /_/ /_ / / /_ / __/_ / /_/ /_/ \__,_/ /_/ /_/ /____/ _ .___/ \____/ /_/ \__/ \___/ /_/ /_/ @clappcodes/transporter
import route from '@clappcodes/transporter/route'; import { BroadcastStream, transform } from '@clappcodes/transporter/stream'; const toUpperCase = route.post('/toUpperCase', ({ request }) => request.body ?.pipeThrough(new TextDecoderStream()) .pipeThrough(transform.toUpperCase()) .pipeThrough(new TextEncoderStream())); const echo = route.post('/echo', (ctx) => { const stream = new BroadcastStream(); ctx.request.body?.pipeTo(stream.writable); ctx.headers.set('content-type', 'text/event-stream'); return stream.readable; }); route(route.cors(), echo, toUpperCase) .serve({ port: 3000 });
import('https://esm.sh/@clappcodes/transporter/stream') .then(({ transport, transform }) => transport.pipe( transport.text(`https://transporter.deno.dev/toUpperCase`), transport.text(`https://transporter.deno.dev/echo`), transform.toUpperCase(), ) ) .then((stream) => { stream.read(console.log); stream.write('Hello World'); });
import { transport } from "@clappcodes/transporter/stream"; const stream = transport.pipe( transport.text("/toUpperCase", /** toUpperCase */) transport.text("/echo", /** echo */) ); stream.read(console.log); stream.write("Hello"); // => HELLO
Add Package
deno add jsr:@clappcodes/transporter
Import symbol
import * as transporter from "@clappcodes/transporter";
---- OR ----
Import directly with a jsr specifier
import * as transporter from "jsr:@clappcodes/transporter";
Add Package
npx jsr add @clappcodes/transporter
Import symbol
import * as transporter from "@clappcodes/transporter";
Add Package
yarn dlx jsr add @clappcodes/transporter
Import symbol
import * as transporter from "@clappcodes/transporter";
Add Package
pnpm dlx jsr add @clappcodes/transporter
Import symbol
import * as transporter from "@clappcodes/transporter";
Add Package
bunx jsr add @clappcodes/transporter
Import symbol
import * as transporter from "@clappcodes/transporter";