2.1.10 • Published 2 years ago

@leaf-x/ali-cloud-gateway v2.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Gateway

Ali cloud gateway.

Installation

npm install @leaf-x/ali-cloud-gateway --save

Parameters

NameDefault ValueDescription
appKeyRequired fieldGateway authorization application key.
appSecretRequired fieldGateway authorization application secret.
stageRELEASEGateway runtime environment.
timeout3000Set the global request timeout.
headersSet the global request headers.

Use

import {gateway} from '@leaf-x/ali-cloud-gateway';

const {request,socket} = gateway({
  appKey: '2135455621223',
  appSecret: 'MjEzNTQ1NTYyMTIyMw==',
  stage: "RELEASE,
});

// Request
await request('https://www.leaf-x.app/').then(result=> console.info(result));

// Socket
socket.connect();

socket.on('OPEN', (success: string) => {
// do something
});

socket.on('CLOSE', (success: string) => {
// do something
});

socket.on('MESSAGE', (message: string) => {
 // do something
});

socket.on('ERROR', (error: Record<string, unknown>) => {
// do something
});

socket.on('SIGN_UP', (success: string) => {
// do something
});

socket.on('SIGN_OUT', (success: string) => {
// do something
});

socket.on('HEARTBEAT', (success: string) => {
// do something
});

SOCKET.on('RECONNECT', (success: string) => {
// do something
});

SOCKET.on('SEND', (data: Record<string, unknown>) => {
// do something
});

socket.send("https://www.leaf-x.app/");

socket.close();

React Native

npm install @leaf-x/ali-cloud-gateway --save npm install react-native-url-polyfill --save

import 'react-native-url-polyfill/auto';

react-native-crypto

npm install --save react-native-crypto

install peer deps

npm install --save react-native-randombytes react-native link react-native-randombytes # on RN >= 0.60, instead do: cd iOS && pod install

install latest rn-nodeify

npm install --save-dev rn-nodeify

install node core shims and recursively hack package.json files

in ./node_modules to add/update the "browser"/"react-native" field with relevant mappings

./node_modules/.bin/rn-nodeify --hack --install

rn-nodeify will create a shim.js in the project root directory

// index.ios.js or index.android.js
// make sure you use `import` and not require!
import './shim.js';
import crypto from 'crypto';
// ...the rest of your code
2.1.10

2 years ago

2.1.9

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.5

2 years ago

2.1.8

2 years ago

2.1.7

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago