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

The error message is being returned as "[object Object]." in resolve #916

Open
yadsbah opened this issue Nov 12, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@yadsbah
Copy link

yadsbah commented Nov 12, 2024

What version of Elysia is running?

1.1.24

What platform is your computer?

Mac

What steps can reproduce the bug?

from 1.1.17 and Later errors that returns from resolve or derive are not parse and body is
[object Object]

export const accountAuther = ({
  IN,
  NOTIN,
  Ignore = false,
}: {
  IN?: AccountType[];
  NOTIN?: AccountType[];
  Ignore?: boolean;
}) =>
  new Elysia().use(bearer()).resolve(
    {
      as: "scoped",
    },
    async ({ error, bearer, set }) => {
      if (Ignore) {
        return error(404, {
          error: "Account not authorized",
        });
      }
      set.headers["content-type"] = "application/json";

      if (!bearer) {
        return error(404, {
          error: "Bearer token not found",
        });
      }

      const dataFromAuth = verifyJWT(bearer);

      if (!dataFromAuth) {
        return error(404, {
          error: "Authorization key not valid",
        });
      }

      const account = await validateAccount({
        id: dataFromAuth.id,
        updatedAt: dataFromAuth.updatedAt,
      });

      if (!account)
        return error(404, {
          error: "Account not found",
        });

      if (IN && IN.length > 0 && !IN.includes(account.type)) {
        return error(401, {
          error: "Account not authorized",
        });
      }

      if (NOTIN && NOTIN.length > 0 && NOTIN.includes(account.type)) {
        return error(401, {
          error: "Account not authorized",
        });
      }

      // Check if account is banned
      if (account.accountState === AccountState.BLOCKED) {
        return error(403, {
          error: "Account is blocked",
        });
      }

   

      return {
        account: account!,
      };
    }
  );

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?

No response

@yadsbah yadsbah added the bug Something isn't working label Nov 12, 2024
@DIEGOHORVATTI
Copy link

yes, up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants