Skip to content

refactor: define types, router 4 support - #1

Open
reslear wants to merge 1 commit into
grafikri:developfrom
reslear:patch-1
Open

refactor: define types, router 4 support#1
reslear wants to merge 1 commit into
grafikri:developfrom
reslear:patch-1

Conversation

@reslear

@reslear reslear commented Jun 17, 2021

Copy link
Copy Markdown

No description provided.

@grafikri
grafikri marked this pull request as ready for review June 17, 2021 08:34
Comment thread src/index.ts

export default (datas?: any) => async (to: Route, from: Route, next: NavigationGuardNext) => {
// TODO: refactor
declare interface RouterMiddlewareContext {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this approach is not true. Because this line restricts the developer from being sent custom data to the middleware.

@reslear reslear Jun 17, 2021

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course, need like declare module 'name'
for example vue router meta

declare module 'vue-router' {
  interface RouteMeta {
    // is optional
    isAdmin?: boolean
    // must be declared by every route
    requiresAuth: boolean
  }
}

but i don't understand how it works, need investigate, maybe you help?

@grafikri

Copy link
Copy Markdown
Owner

By the way, Maybe I will mark this repository as deprecated(after released a new version and more good interface) because I found a bug for chained middlewares.

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 this pull request may close these issues.

2 participants