# @samhammer/vue-middleware-pipelines

> possibility to add middleware logic to the vue router

Latest version **0.5.0** (published 2019-08-22) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @samhammer/vue-middleware-pipelines
pnpm add @samhammer/vue-middleware-pipelines
yarn add @samhammer/vue-middleware-pipelines
bun add @samhammer/vue-middleware-pipelines
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2019-08-22 |
| First published | 2019-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | SamhammerAG |
| Maintainers | agentschmitt, aschiffmann, code-chris, roemer11, rstich |

## Links

- npm: https://www.npmjs.com/package/@samhammer/vue-middleware-pipelines
- Homepage: https://github.com/SamhammerAG/vue-middleware-pipelines
- Issues: https://github.com/SamhammerAG/vue-middleware-pipelines/issues
- npm.io page: https://npm.io/package/@samhammer/vue-middleware-pipelines

## Dependencies (3)

- [vue](https://npm.io/package/vue.md) ^2.6.6
- [vuex](https://npm.io/package/vuex.md) ^3.1.1
- [vue-router](https://npm.io/package/vue-router.md) ^3.0.1

## Recent versions

- 0.5.0 (latest) — 2019-08-22
- 0.1.5 — 2019-08-22
- 0.1.4 — 2019-08-22
- 0.1.3 — 2019-08-22
- 0.1.2 — 2019-08-22
- 0.1.1 — 2019-08-22
- 0.1.0 — 2019-08-22

## README

# Vue-Middleware-Pipeplines
Possibility to add middleware logic to the vue router
This package contains the routing logic of Dotunj.
For more details see https://github.com/Dotunj/vue-middleware-pipelines

## How to use
Register Middleware in router:
```js
import routerMiddleware from './routerMiddleware';
...
routerMiddleware.registerMiddleware(router, AuthStore);
```

Write a function to set the next route (e.g. in a new module called authMiddleware):
```js
import { Context } from '@samhammer/vue-middleware-pipelines';

export default function authMiddleware(context: Context): void {
    if (!context.store.getters.auth.isLoggedIn) {
        return context.next({
            name: 'login',
        });
    }

    return context.next();
}
```

Add middleware to route:
```js
import authMiddleware from './authMiddleware';
...
    routes: [
    ...
        {
            path: '/agentchat',
            name: 'agentchat',
            component: () => import('@/views/AgentChat.vue'),
            meta: {
                middleware: [
                    authMiddleware,
                ],
            },
        },
    ...
    ]
```

## How to publish

For publishing an npm account that is referenced to the organization is required.

See the following how to:

https://yarnpkg.com/en/docs/publishing-a-package

https://docs.npmjs.com/getting-started/publishing-npm-packages

If everything is configured correctly just count up the version number in our package.json and execute one of the following commands:

```bash
yarn run build
yarn publish

npm run build
npm publish --access public
```

## License

vue-middleware-pipelines is released under the MIT License. See LICENSE file for details.

---
_Source: https://npm.io/package/@samhammer/vue-middleware-pipelines · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
