npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lb-connector-alimns

v0.2.0

Published

Loopback connector module which allow to send sms via alimns

Downloads

3

Readme

lb-connector-alimns

lb-connector-alimns is the Loopback connector module which allow to send emails via Mandrill.

1. Installation

npm install lb-connector-alimns --save

2. Configuration

datasources.json

{
    "alimns": {
        "connector": "lb-connector-alimns",
        "apiUser": "[your api user here]",
        "apiKey": "[your api key here]",
        "apiKeySecret": '[your api key here]'
    }
}

model-config.json

{
    "SMS": {
        "dataSource": "alimns",
        "public": false
    }
}

Additionaly you can set defaults

{
    "alimns": {
        "connector": "lb-connector-alimns",
        "apiUser": "[your api user here]",
        "apiKey": "[your api key here]",
        "apiKeySecret": '[your api key here]'
    }
}

Configuration in JavaScript

var DataSource = require('loopback-datasource-juggler').DataSource;
var dsalimns = new DataSource('lb-connector-alimns', {
     "apiUser": "[your api user here]",
     "apiKey": "[your api key here]",
     "apiKeySecret": '[your api key here]'
});
loopback.SMS.attachTo(dsalimns);

3. Use

loopback.SMS.send({
    from: "[your signature]",
    to: {"mobilePhone": {"template variable": "value"}},
    subject: "[your topic]",
    template: "[your sms template]"
},
function(err, result) {
    if(err) {
        console.log('Upppss something crash');
        return;
    }
    console.log(result);
});

4. notes

使用阿里的mns发送短信时,遇到过以下坑:

  1. 无官方nodejs sdk,第三方ali-nms匹配有阻抗,按官网说明[https://help.aliyun.com/document_detail/27497.html?spm=5176.product27412.6.733.Frl2zn],整个发送出去的XML都应是utf-8格式编码,ali-mns 也是如此对xml进行编码的。 但是DirectSMS中签名使用的unicode 16编码,结果导致调用接口成功,而手机收不到短信。这好像是个Bug,不知道什么时候能改好。 目前只能自己把签名改成unicode编码。

  2. 不同端点发送效果有差别,在测试的过程中,使用华东2区(上海)端点发送,手机收不到短信,而使用华东1区(杭州)端点发送,就能收到短信。 因此,这里干脆把端点固定在杭州,请注意!!!

  3. 发送短信时,选择类型 multiContent 比 类型 singleContent发送效果要好,不知何故! 因此,这里也一律选择 multiContent 方式发送。