Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for elysia 0.8 #9

Open
shrinathprabhu opened this issue Jan 17, 2024 · 2 comments
Open

Add support for elysia 0.8 #9

shrinathprabhu opened this issue Jan 17, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@shrinathprabhu
Copy link

Hey @Gusb3ll , can you add support for elysia 0.8, the current version of elysia-compression is breaking in elysia 0.8

@Gusb3ll Gusb3ll self-assigned this Jan 17, 2024
@Gusb3ll Gusb3ll added the enhancement New feature or request label Jan 17, 2024
@cupcakearmy
Copy link

Same issue here, was wondering why cookies were not working and cors failing xD

@shrinathprabhu
Copy link
Author

If anyone is facing the same issue, here's how I fixed it for mine

import { Elysia } from "elysia";
import { gzipSync } from "bun";

export function compression() {
  return new Elysia({
    name: '@elysiaplugin/compression'
  }).mapResponse(({ response }) => {
    return new Response(
      gzipSync(
        typeof response === "object"
          ? JSON.stringify(response)
          : response.toString()
      )
    );
  });
}

Referenced from Official Elysia Docs: https://elysiajs.com/life-cycle/map-response.html#example

And then you can use it as a plugin middleware for your main app

app.use(compression())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants