question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Koa@Next example not working

See original GitHub issue

having the imports, a valid htpasswd and its path testet, basic set like in the example, using koa next … app.use(koaAuth(basic)); results in

TypeError: koaAuth is not a function
    at file:///mnt/.........../server.mjs:114:13
    at Generator.next (<anonymous>)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
MartinWickmancommented, Sep 27, 2019

It fails because Koa requires next() to be await next(). This can result in really weird errors. In @BananaAcid 's case I belive it will always continue running the next middleware, which is probably not what is intended.

One way I could make it work is this:

        return async (ctx, next) => {
            let passed = false;
            digest.check(ctx.req, ctx.res, (req, res, err) => {
                if (err) {
                    throw err;
                } else {
                    passed = true;
                   //await next() doesn't work here since callback is not called async
                }
            });

            if (passed) {
                await next();
            }
        }
1reaction
gevorgcommented, Feb 2, 2020

Koa integration removed, please check https://github.com/http-auth/http-auth-koa

Read more comments on GitHub >

github_iconTop Results From Across the Web

[@types/koa-router] incompatible type with koa #36161 - GitHub
I tried using the @types/koa-router package and had problems. I tried using the latest stable version of tsc.
Read more >
Koa - next generation web framework for node.js
Introduction. Koa is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more...
Read more >
koa js: What does "next" refer to, and can cascading be ...
I'm assuming not, and the behavior is just dependent on the argument order in the function. If this is the case, then how...
Read more >
next generation web framework for node.js
Koa is a new web framework designed by the team behind. Express, which aims to be a smaller, more expressive, and more robust...
Read more >
koa-next - npm Package Health Analysis - Snyk
In the past month we didn't find any pull request activity or change in issues status has been detected for the GitHub repository....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found