Using Dashport as a middleware leads to compile error
See original GitHub issueHi there 👋
First all, thanks for making this library. Looks like the perfect thing I need for my use case. The only problem now is that I am following the documentation and it does not seem to work. In the documentation you see the following lines:
Dashport is now ready to authenticate. Dashport’s authenticate method acts as middleware, so it can be used like so
import { dashport, googStrat, serializerA, deserializerA } from './dashportConfig.ts';
const xx = async (ctx: any, next: any) => {
ctx.response.body = 'This is a private page!';
}
router.get('/privatepage', dashport.authenticate(googStrat, serializerA, deserializerA), xx)
But if I do so, I get the following compilation error
Overload 1 of 2, '(name: string, path: string, ...middleware: RouterMiddleware<RouteParams, Record<string, any>>[]): Router<RouteParams, Record<string, any>>', gave the following error.
Argument of type '(ctx: any, next: any) => Promise<void>' is not assignable to parameter of type 'string'. Overload 2 of 2, '(path: string, ...middleware: RouterMiddleware<RouteParams, Record<string, any>>[]): Router<RouteParams, Record<string, any>>', gave the following error.
Argument of type 'Function' is not assignable to parameter of type 'RouterMiddleware<RouteParams, Record<string, any>>'.
Type 'Function' provides no match for the signature '(context: RouterContext<RouteParams, Record<string, any>>, next: () => Promise<void>): void | Promise<void>'.
router.get('/privatepage', xx, dashport.authenticate(googStrat, serializerA, deserializerA))
Any ideas what could be going wrong? Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Router.use() requires middleware function but got a Object ...
I was getting the same error message but had a different issue. Posting for others that are stuck on same.
Read more >How To Implement Custom Error Responses in Express - Auth0
Let's see what you need to get started with error response customization for 401 Unauthorized and 403 Forbidden errors in Express. An ...
Read more >Express.js Error Handling 101 - ButterCMS
Set up error handling middleware for operational errors: In an Express application, it is essential to have all your error handlers in a ......
Read more >Understanding Vue middleware pipelines - LogRocket Blog
For example, let's say we have a dashboard route that can only be accessed by authenticated users, we can make use of an...
Read more >Advanced Features: Middleware - Next.js
Learn how to use Middleware to run code before a request is completed. ... values need to be constants so they can be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey guys, 6.5.0 is the latest version of Oak that the module is currently working with. Oak has made many, many changes since our initial release and every type change they make affects the functionality of the module. This is clearly a problem in need of a solution and we’re working on it. In the meantime, I think Dashport, unfortunately, will need to be run with Oak 6.5.0
@finlaydotb I had the same issue, but it looks like it’s a typescript definitions mismatch between what Oak wants and what Dashport gives. I can’t dig too much deeper but the following worked for me: