log-push

push log by aliyun sms or server酱

Usage no npm install needed!

<script type="module">
  import logPush from 'https://cdn.skypack.dev/log-push';
</script>

README

log-push

Note: This module just can be used in China

Push something (like server logs) to phone or wechat. It use Aliyun SMS to do sms and use Server酱 to do wechat notification

Install

npm install log-push

Config

Push by SMS

param type description
accessKeyID string access key id, get from aliyun
accessKeySecret string access key secret, get from aliyun
paramString object ali sms param which you have defined on aliyun sms dashboard
recNum array phone numbers of users
signName string ali sms param, get from aliyun sms dashboard
templateCode string ali sms param, get from aliyun sms dashboard
notifyWay string must be sms

Push by Wechat

param type description
serverJiangKey string access key from server酱
wechatText string the title of wechat message
wechatDesp string the content of wechat message

NOTE: All parameters is required

Usage

const logPush = require("log-push");

const configWechat = {
  serverJiangKey: process.env.SERVER_JIANG_KEY,
  wechatText: '数星星',
  wechatDesp: `一共有${Math.ceil(Math.random() * 100)}个`
};

const configSMS = {
  accessKeyID       : process.env.ALI_SMS_ACCESSKEYID,
  accessKeySecret   : process.env.ALI_SMS_ACCESSKEYSECRET,
  paramString       : {code: '一起去大保健'},
  recNum            : ['17705143392'],
  signName          : '久康云',
  templateCode      : 'SMS_28100008',
  notifyWay         : 'sms',
};

logPush(configWechat, (err) => console.log(err));
logPush(configSMS, (err) => console.log(err));