question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support compression

See original GitHub issue

Hello I really love marblejs!! I want to use it on my project and also contribute it if I can. BTW is there a talk channel for marblejs? like spectrum, gitter, discord


I wanna compress response(gzip) like express-compression. Middleware looks like only update req but not res

// effects.combiner.ts
export const combineMiddlewares = <T, U>
  (...effects: Effect<T, T, U>[]) =>
  (input$: Observable<T>, client: U, meta: EffectMetadata): Observable<T> =>
    effects.reduce((i$, effect) => effect(i$, client, meta!), input$);

So user can not add compress feature by add a compression middleware.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JozefFlakuscommented, May 7, 2019

Thanks for kind words! There is already a Gitter channel for Marble.js but looks like nobody wants to talk ¯_(ツ)_/¯

For response compression, you can make use of output$ interceptor where you can attach a compression logic, which for example can be piped to the response.

This is only a dummy idea of how it can be implemented. More details you can find here.

const output$: HttpOutputEffect = res$ =>
  res$.pipe(
    // lets assume that res.body is a ReadableStream
    // and 'accept-encoding' is set to 'gzip'
    map(res =>  ({
      ...res,
      headers: { ...res.headers, 'Content-Encoding': 'gzip' },
      body: res.body.pipe(zlib.createGzip()),
    }),
  );
1reaction
JozefFlakuscommented, May 8, 2019

The idea for this improvement will look like this:

const output$: HttpOutputEffect = (res$, _, { initiator }) =>
  res$.pipe(
    // lets assume that res.body is a ReadableStream
    // and 'initiator.headers.accept-encoding' is set to 'gzip'
    map(res =>  ({
      ...res,
      headers: { ...res.headers, 'Content-Encoding': 'gzip' },
      body: res.body.pipe(zlib.createGzip()),
    }),
  );

So in general, output$ effect will have an ability to get an initiator which will contain a contextual object (eg. HttpRequest), so the developer will be able to grab all relevant information when needed from Effect metadata. The same pattern is used inside ErrorEffect where you can grab from meta the error object.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support Compression - Jobst USA
Just like medical compression stockings, support stockings can help to counteract venous symptoms in combating venous problems such as edema.
Read more >
20-30mmHg Firm Support Compression Socks & Stockings
20-30mm Hg is categorized as firm support. It builds upon the benefits of the 8-15mmHg and 15-20mmHg compressions and assists in the treatment...
Read more >
Compression Socks Gifts at Support Plus
Our Stockings come in four levels of medically correct compression for better circulation and relief from achy legs. Mild Support - for tired...
Read more >
Support & Compression Levels - FUTURO
Provides therapeutic compression to help relieve moderate-severe symptoms of chronic tired, aching legs, leg pain, varicosities, post-sclerotherapy, and edema.
Read more >
compression socks - Amazon.com
Sheer Compression Stockings for Women, 8-15 mmHg Support, Light Denier, Knee High, Closed Toe. 4.3 out of 5 stars 199. Save 12%.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found