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

addError is undefined when added as middleware to Elysia 0.8.9 project #1

Closed
nathankleyn opened this issue Jan 20, 2024 · 0 comments
Closed

Comments

@nathankleyn
Copy link

Hello!

Firstly, a huge thanks for this project — the time and effort you've put into making sure this is really well thought out with awesome tests and a proper security mindset is amazing. We're really grateful and plan to use this in a new project.

I've tried to set up a Elysia 0.8.9 project with this package, however the server fails to start as soon as I add basicAuth as middleware with the following error:

TypeError: app.state("basicAuthRealm", null).state("basicAuthUser", null).addError is not a function. (In 'app.state("basicAuthRealm", null).state("basicAuthUser", null).addError({ BASIC_AUTH_ERROR: BasicAuthError })', 'app.state("basicAuthRealm", null).state("basicAuthUser", null).addError' is undefined)
      at /<redacted>/node_modules/@eelkevdbos/elysia-basic-auth/dist/index.js:102:10
      at _use (/<redacted>/node_modules/elysia/dist/bun/index.js:361:32813)
      at /<redacted>/src/index.ts:7:20
 97 |     };
 98 |     const credentialsMap = newCredentialsMap(options.credentials);
 99 |     const inScope = newScopePredicate(options.scope);
100 |     const skipRequest = (request) => options.skipCorsPreflight && isCORSPreflightRequest(request);
101 |     return (app) => app
102 |         .state('basicAuthRealm', null)
               ^

It appears as though despite the fact there is a peerDependency on ^0.8.1 the actual bun.lockb contains 0.6.16:

$ bun pm ls
elysia-basic-auth node_modules (11)
├── bun-types@0.8.1
├── elysia@0.6.16
├── prettier@3.0.3

In Elysia 0.7.0, addError was renamed to error which I think is the root cause of the above issue.

I have prepared a small PR fix for this, which I will link to this issue shortly.

eelkevdbos added a commit that referenced this issue Feb 6, 2024
Fixes #1 addError is undefined when added as middleware to Elysia 0.8.9
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

Successfully merging a pull request may close this issue.

1 participant