Skip to content

Using Dashport as a middleware leads to compile error #44

Open
@finlaydotb

Description

@finlaydotb

Hi 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions