{"id":15156297,"url":"https://github.com/zephyrpersonal/vue-router-middlewares","last_synced_at":"2026-01-20T07:03:27.552Z","repository":{"id":89375282,"uuid":"127263584","full_name":"zephyrpersonal/vue-router-middlewares","owner":"zephyrpersonal","description":"A simple koa-like middleware wrapper for vue-router","archived":false,"fork":false,"pushed_at":"2018-03-29T08:51:39.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-18T09:10:37.879Z","etag":null,"topics":["middleware","vue","vue-router"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zephyrpersonal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-29T08:45:59.000Z","updated_at":"2018-03-29T08:51:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"5a95f559-b0f3-40b8-a6fa-b4d21d0f9e7a","html_url":"https://github.com/zephyrpersonal/vue-router-middlewares","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"badb8e41904d8e1205c23ca021cbbdaaeb082641"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zephyrpersonal/vue-router-middlewares","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephyrpersonal%2Fvue-router-middlewares","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephyrpersonal%2Fvue-router-middlewares/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephyrpersonal%2Fvue-router-middlewares/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephyrpersonal%2Fvue-router-middlewares/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zephyrpersonal","download_url":"https://codeload.github.com/zephyrpersonal/vue-router-middlewares/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephyrpersonal%2Fvue-router-middlewares/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28597985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["middleware","vue","vue-router"],"created_at":"2024-09-26T19:03:28.932Z","updated_at":"2026-01-20T07:03:27.537Z","avatar_url":"https://github.com/zephyrpersonal.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vue-Route-Middleware\n\nA simple koa-like middleware wrapper for vue-router\n\n## Caution\n\nThis module is still being developed and no guaruntee on production enviorment\n\n## Features\n\n* Koa-like api\n* Support either async or sync middleware\n* A context object to store data through the whole routing lifecycle\n\n## Install\n\nBy script tag\n\n```html\n\u003cscript src=\"cdn/vue.js\"\u003e\u003c/script\u003e  \n\u003cscript src=\"cdn/vue-router.js\"\u003e\u003c/script\u003e  \n\u003cscript src=\"node_modules/vue-router-middleware/lib/index.js\"\u003e\u003c/script\u003e  \n```\n\nBy commonjs\n\n```bash\nnpm install vue-router-middlewares -S\n```\n\n```js\nimport vueRouterWrapper from 'vue-router-middlewares'\n// or\nconst vueRouterWrapper = require('vue-router-middlewares')\n```\n\n## How to use\n\nHere is a simple snippet to show the use case\n\n```js\n// create a vue-router instance\nconst originRouter = new VueRouter({\n  ...// here your routes config\n})\n\n// wrapped it with vue-route-middleware\nconst router = vueRouterWrapper(originRouter, { debug: true })\n\n// support chainning\nrouter\n  // async middleware\n  .use(async(ctx,next) =\u003e {\n    const res = await fetch('/path/to/api')\n    await next()\n\n    // logic if passed later middleware\n    remoteLog()\n  })\n\n  // sync middleware\n  .use((ctx,next) =\u003e {\n    next()\n  })\n\n  .use((ctx,next) =\u003e {\n    // ignore the later middlewares\n    if(!ctx.auth) return\n    next()\n  })\n\n  // stop routing if getting errors\n  .use(ctx,next) =\u003e {\n    throw new Error('oops')\n  })\n\nnew Vue({\n  router\n}).$mount('#app')\n```\n\nthe complete example could be found in the repo.\n\n## Context\n\nI've delegate some params from origin vue-router instance to the ctx object passed to the middleware.\n\n'path', 'query', 'params', 'meta', 'name', 'hash', 'matched' from to-router-instance are mapped to ctx[key]\n\nremember they are just writeable params, if you try to set value on them, it will generate or overwrite ctx[_key]\n\nand if you rewrite ctx.path, if the middlewares all passed, the router will change its destination like a redirecting.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzephyrpersonal%2Fvue-router-middlewares","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzephyrpersonal%2Fvue-router-middlewares","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzephyrpersonal%2Fvue-router-middlewares/lists"}