New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@clappcodes/transporter

Package Overview
Dependencies
Maintainers
0
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clappcodes/transporter

Transport Web Stream

latest
Source
npmnpm
Version
0.5.1
Version published
Weekly downloads
0
-100%
Maintainers
0
Weekly downloads
 
Created
Source
________                                                        _____               
___  __/______________ ________ ________________ ______ __________  /______ ________
__  /   __  ___/_  __ `/__  __ \__  ___/___  __ \_  __ \__  ___/_  __/_  _ \__  ___/
_  /    _  /    / /_/ / _  / / /_(__  ) __  /_/ // /_/ /_  /    / /_  /  __/_  /    
/_/     /_/     \__,_/  /_/ /_/ /____/  _  .___/ \____/ /_/     \__/  \___/ /_/     
                                        /_/                                         
@clappcodes/transporter

Request handler

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 });

Quick start

  • Just paste in console
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

FAQs

Package last updated on 12 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts