Giter VIP home page Giter VIP logo

vue-router-middleware-plugin's Introduction

Vue Router Middleware Plugin

A vue-router middleware pipeline (Nuxt like middlewares in Vue).

npm version Build Status code cove Codacy Badge vue-router-middleware-plugin

The plugin utilizes vue-router navigation guards to implement easy to use, readable and more organized middlewares for your routes.

Installation

Install using NPM

npm i -S vue-router-middleware-plugin

Install using Yarn

yarn add vue-router-middleware-plugin

Get Started in 3 Easy Steps

  1. Register middleware plugin in your app.

    import Vue from 'vue'
    import MiddlewarePlugin from 'vue-router-middleware-plugin'
    import router from '@/path-to-router'
    
    Vue.use(MiddlewarePlugin, router)
  2. Create a middleware function.

    import store from '@/path-to-store'
    
    export default ({ to, from, redirect }) => {
      if (!store.getters.isLoggedIn) {
        redirect('/login')
      }
    }
  3. Attach middleware to a route.

    import AuthMiddleware from '@/path-to-auth-middleware'
    
    export default new VueRouter({
      routes: [
        {
          path: '/',
          meta: {
            middleware: AuthMiddleware
          },
          .
          .
        },

Note: You may attach multiple middlewares to a route.

  {
    path: '/login',
    meta: {
      middleware: [LoggerMiddleware, AnalyticsMiddleware]
    },
    .
    .
  },

Easy as that to get started.

๐Ÿ‘€ For advanced features like global middlewares and middleware context continue to Documentations.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

vue-router-middleware-plugin's People

Contributors

dependabot[bot] avatar dsfx3d avatar iodsfx3d avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue-router-middleware-plugin's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @types/node to v13.13.52
  • chore(deps): update dependency @types/node to v20
  • chore(deps): update dependency prettier to v3
  • chore(deps): update dependency tslint to v6
  • chore(deps): update dependency typescript to v5
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • @babel/cli 7.10.0
  • @babel/core 7.10.0
  • @babel/plugin-proposal-class-properties 7.8.3
  • @babel/plugin-proposal-numeric-separator 7.8.3
  • @types/node 13.13.9
  • @babel/plugin-proposal-object-rest-spread 7.10.0
  • @babel/preset-env 7.10.0
  • @babel/preset-typescript 7.9.0
  • @types/jest 25.2.3
  • cz-conventional-changelog 3.2.0
  • commitizen 4.1.2
  • ghooks 2.0.4
  • jest 26.0.1
  • prettier 2.0.5
  • regenerator-runtime 0.13.3
  • semantic-release 16.0.4
  • ts-jest 26.5.1
  • tslint 5.20.1
  • tslint-config-prettier 1.18.0
  • tslint-plugin-prettier 2.3.0
  • vuepress 1.5.0
  • typescript 3.9.3
travis
.travis.yml
  • node 12

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.