# p6-service

> Extendable service system

Latest version **0.0.7** (published 2018-01-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install p6-service
pnpm add p6-service
yarn add p6-service
bun add p6-service
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2018-01-29 |
| First published | 2018-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tuan Nguyen |
| Maintainers | picosix |

## Links

- npm: https://www.npmjs.com/package/p6-service
- npm.io page: https://npm.io/package/p6-service

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [winston](https://npm.io/package/winston.md) ^2.4.0
- [change-case](https://npm.io/package/change-case.md) ^3.0.1

## Recent versions

- 0.0.7 (latest) — 2018-01-29
- 0.0.6 — 2018-01-29
- 0.0.5 — 2018-01-28
- 0.0.4 — 2018-01-28
- 0.0.3 — 2018-01-28
- 0.0.2 — 2018-01-28
- 0.0.1 — 2018-01-28

## README

# p6-service

## Hooks - The heart of our system

### Types

- `before-global` - Run before all service 
- `before-service` - Run before a service, detect by SID
- `after-service` - Run after a service, , detect by SID
- `after-global` - Run after all service

### How to result of service will be solve?

- Run `before-global` -> `beforeGlobalResult`. `ServiceResult` is `beforeGlobalResult`
- Run `before-service` with latest params is `ServiceResult` -> `beforeServiceResult`. `ServiceResult` is `Object.assign({}, ServiceResult, beforeServiceResult)`
- Run `after-service` with latest params is `ServiceResult` -> `afterServiceResult`. `ServiceResult` is `Object.assign({}, ServiceResult, afterServiceResult)`
- Run `after-global` with **ONE** params is `ServiceResult` -> `afterGlobalResult`. `ServiceResult` is `Object.assign({}, ServiceResult, afterGlobalResult)`
- Return `ServiceResult`

### Break the chain

You cann break the chain of hook by using flag `__break` on your return result.

- `before-global` -> break after run **ALL** `before-global` hooks
- `before-service` -> break after run **ALL** `before-global` and `before-service` hooks
- `handler` -> break after run **ALL** `before-global`, `before-service` hooks an your main `handler`
- `after-service` -> break after run **ALL** `before-global`, `before-service` hooks, your main `handler` and `after-service`
- `after-global` As default mode, your service will run through your handler and all hooks

---
_Source: https://npm.io/package/p6-service · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
