Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bpfaas/common

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bpfaas/common

bpfaas Common library

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Common library

  • Setup
  • Distributed identity
  • ErrorCode
  • Msg
  • Auth

Setup

npm i @bpfaas/common

set config in tsconfig.json

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

Distributed identity

use api

import {identity} from '@bpfaas/common'

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

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

// id length.
identity.idLength == 32

use decorator

import {Identity} from '@bpfaas/common'

class Demo {
  @Identity
  id: string;
}

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

ErrorCode

import {errorCode, isErrorCode, getErrorCodeMsg} from '@bpfaas/common';

// get the errCode
errorCode.OK                // 200
errorCode.OK_SYNC           // 202
errorCode.PARAMETER_ERROR   // 400
errorCode.UNAUTHORIZE       // 401
errorCode.NOT_FOUND         // 404
errorCode.OPERATOR_EXPIRED  // 408
errorCode.OPERATOR_ERROR    // 417
errorCode.APPCALL_LIMITED   // 444
errorCode.OPERATOR_LIMITED  // 445
errorCode.SERVICE_ERROR     // 500
errorCode.SERVICE_UNAVAILABLE  // 504

isErrorCode(200) == true
getErrorCodeMsg(errorCode.OPERATOR_EXPIRED) // 'OPERATOR_EXPIRED'

Msg

Network message package.

import {Msg, errorCode} from '@bpfaas/common';

let msg:Msg = {
  err_code: errorCode.OK,
  err_msg: 'error message',
  err_subcode: 'bll error code',
  data: {
    ...
  }
}

Auth

Get response user auth info.

import {auth} from '@bpfaas/common';

auth.headerTenantIdKey  // of-tid
auth.headerUserIdKey  // of-uid

auth.getTenantId(restObj)
auth.getUserId(restObj)

auth.getFeignData(restObj)

Keywords

FAQs

Package last updated on 01 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc