Skip to content

Several Bugs: TypeError: t.Module, redirect, cookie.set, getting data from x-www-form-urlencoded content type #1161

@WolfieLeader

Description

@WolfieLeader

What version of Elysia is running?

1.2.25

What platform is your computer?

Microsoft Windows NT 10.0.26100.0 x64

What steps can reproduce the bug?

Im using Elysia@1.2.25 in NodeJS,
I followed the quick start and it broke because of the following error:

elysia@1.2.25_@sinclair+typebox@0.33.22_typescript@5.8.2\node_modules\elysia\dist\cjs\index.js:96
      typebox: import_type_system.t.Module({}),
                                    ^
TypeError: import_type_system.t.Module is not a function

After removing the node_modules for couple of times it finnaly worked.

Then I tried to get data from content type: application/x-www-form-urlencoded
I read the docs and it says:

By default, Elysia will parse the body with content-type of:

text/plain
application/json
multipart/form-data
application/x-www-form-urlencoded

A workaround was this:

  const raw = await request.text();
  const form = Object.fromEntries(new URLSearchParams(raw));

Then I tried setting two types of cookies access-token and refresh-token which didn't work because when i did cookie["access-token"].set = ... and then the same thing to the refresh token, it only executed for the first setter.

another problem was with another example from the docs

import { Elysia } from 'elysia'

new Elysia()
    .get('/', ({ redirect }) => {
        return redirect('https://youtu.be/whpVWVWBW4U?&t=8')
    })
    .get('/custom-status', ({ redirect }) => {
        // You can also set custom status to redirect
        return redirect('https://youtu.be/whpVWVWBW4U?&t=8', 302)
    })
    .listen(3000)

which gives immutable error instead of redirecting

Thank you!

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions