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

@elysiajs/jwt ^1.0.2 breaks type inference for handler functions #296

Open
Limitless-Kode opened this issue Mar 26, 2024 · 0 comments
Open

Comments

@Limitless-Kode
Copy link

I added @elysiajs/jwt ^1.0.2 to my project and initialised it with the .use hook. Everything seems to work fine however it breaks the type inference causing the handler method parameters to implicitly return a type of any.

    app.use(jwt({
        secret: env.JWT_SECRET,
        algorithms: ["HS256"],
        maxAge: "1d",
        clockTolerance: 0
    }))
    .get("/", async ({query, jwt, set, cookie: { auth }}) => {
            const verified = await jwt.verify(auth.value)
            if (!verified) {
                set.status = 401
                return 'Unauthorized'
            }
            const users = await AuthenticationController.all(query);
            return ApiResponse.success(users);
        },
        {
            detail: { tags: ["Authentication"] }
        }
    )

jwt, query, set, and auth now implicitly have the type of any

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

No branches or pull requests

1 participant