0.0.11 • Published 6 years ago

vue-router-guards v0.0.11

Weekly downloads
1
License
ISC
Repository
gitlab
Last release
6 years ago

Vue router guards

package for simplify working with guard in vue router

  • Install
npm i -S vue-router-guards
  • Initialize pipeline
import { Pipeline } from "vue-router-guards";

const pipeline = new Pipeline();
  • Guard example
import { GuardResult } from "vue-router-guards";

class AuthGuard {
    execute(to, from) {
        if(user.isAuth()) {
            return new GuardResult(true);
        }
        
        return new GuardResult(false, "/login");
    }
}
  • Use guard
pipeline.use(new AuthGuard());
  • Pass execute method of pipeline in router hook
router.beforeEach((to, from, next) => pipeline.execute(to, from, next));

or

router.beforeEach(pipeline.execute.bind(pipeline));
  • Nuances
  1. Guards executes in order
  2. On first failure subsequent guards will not be executed
0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.3

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

1.0.0

7 years ago