open-index/open-npm huggingface dataset:
npm package: @originforest/common
Description: Common library in originforest
Latest version: 0.0.4

Common library in originforest

- [Setup](#setup)
- [Distributed identity](#distributed-identity)
- [ErrorCode](#errorcode)
- [Msg](#msg)

## Setup

npm i @originforest/common

set config in tsconfig.json

```
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
```

## Distributed identity

use api

```js
import {identity} from '@originforest/common'

// a unique id.
let id = identity.nextId();

// test id.
if (!identity.isValidId(id)) {
}

// id length.
identity.idLength == 32
```

use decorator

```js
import {Identity} from '@originforest/common'

class Demo {
  @Identity
  id: string;
}

// a unique id.
new Demo().id
```

## ErrorCode

```js
import {errorCode, getErrorCodeMsg} from '@originforest/common';

// get the errCode
errorCode.OK                // 200
errorCode.NOT_FOUND         // 404
errorCode.OPERATOR_EXPIRED  // 408

getErrorCodeMsg(errorCode.OPERATOR_EXPIRED) // 'OPERATOR_EXPIRED'
```

## Msg

Network message package.

```js
import {Msg, errorCode} from '@originforest/common';

let msg:Msg = {
  err_code: errorCode.OK
}
```
npm package: @originforest/middleware-auth
Description: auth middleware of originforest in bpframework
Latest version: 0.0.2

# originforest service auth middleware in bpframework.

### Middleware specification

https://github.com/bpcloud/middleware

### usage


#### Setup.

```js
import { Application } from 'bpframework';
import * as middleware_auth from '@bpframework/middleware-auth';

Application.use(middleware_auth.middleware)
Application.runKoa(...);
```

#### Config.

```properties
spring:
  application: xxxxxxxxx      # 服务名字

service_sign:
  faas_service_sign: xxxxxxxxx      # 服务签名
```