elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
9.73k stars 207 forks source link

Cannot destructure cookies in derive anymore #737

Open folland87 opened 1 month ago

folland87 commented 1 month ago

What version of Elysia.JS is running?

1.1.3

What platform is your computer?

Linux 6.5.0-44-generic x86_64 x86_64

What steps can reproduce the bug?

import { Elysia } from "elysia";

const app = new Elysia()
  .derive(({ error, cookie: { accessToken } }) => {
    if (!accessToken) {
      return { isConnected: true };
    }
    return { currentUser: false };
  })
  .get("/hello", async ({ currentUser, error }) => {
    if (currentUser) {
      return { message: "world" };
    }
    return error(401, { message: "Error" });
  })
  .listen(3000);

console.log(
  `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`,
);

What is the expected behavior?

Destructure accessToken as in 1.0.*

What do you see instead?

{"name":"TypeError","message":"Right side of assignment cannot be destructured"}

Additional information

No response

askareija commented 1 month ago

i have this error too after updating elysia