Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ index.d.ts
.vscode/
node_modules/
test/account.js
ts/*.js
ts/*.d.ts
ts/*.js.map
test/*.js
test/*.d.ts
test/*.js.map
Empty file added .sonarcloud.properties
Empty file.
24 changes: 17 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
language: node_js
node_js:
- "6"
- "6"

# Only ci these branches
branches:
only:
- master
only:
- master

# cache:
# directories:
# - $HOME/.npm
# - $HOME/build/InCar/ali-mns/node_modules

before_install:
- "npm install -g typescript gulp-cli"
- "npm install"
- "gulp clean"
- "gulp"
- "npm install"
- "npm run build"

jobs:
include:
# Define the release stage that runs semantic-release
- stage: release
node_js: lts/*
# Advanced: optionally overwrite your default `script` step to skip the tests
# script: skip
deploy:
provider: script
skip_cleanup: true
script:
- npx semantic-release
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# ali-mns (ali-mqs)
[![npm version](https://badge.fury.io/js/ali-mns.svg)](http://badge.fury.io/js/ali-mns)
[![npm version](https://badge.fury.io/js/ali-mqs.svg)](http://badge.fury.io/js/ali-mqs)
# ali-mns-ts

The nodejs sdk for aliyun mns service
> The nodejs sdk for aliyun mns service (TypeScript version)


[![npm version](https://badge.fury.io/js/ali-mns-ts.svg)](http://badge.fury.io/js/ali-mns-ts)
[![Build Status](https://travis-ci.com/Jeff-Tian/ali-mns.svg?branch=master)](https://travis-ci.com/Jeff-Tian/ali-mns)

[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=Jeff-Tian_ali-mns)](https://sonarcloud.io/dashboard?id=Jeff-Tian_ali-mns)

[阿里云消息服务-简体中文-帮助手册](http://armclr.incars.com.cn/Links/AliMNS?lang=zh-Hans)

Expand All @@ -12,17 +16,17 @@ The world largest online sales website www.taobao.com is heavily relying on it.
You can visit [http://www.aliyun.com/product/mns](http://www.aliyun.com/product/mns) for more details.

The original Ali-MQS service has been upgraded and changed it's name to Ali-MNS since June, 2015.
Go to [Migrate](#migrate) part for the old version informations.
Go to [Migrate](#migrate) part for the old version information.

# QuickStart
Use 'npm install ali-mns' to install the package.

```javascript
var AliMNS = require("ali-mns");
var AliMNS = require("ali-mns-ts");
var account = new AliMNS.Account("<your-account-id>", "<your-key-id>", "<your-key-secret>");
var mq = new AliMNS.MQ("<your-mq-name>", account, "hangzhou");
// send message
mq.sendP("Hello ali-mns").then(console.log, console.error);
mq.sendP("Hello ali-mns-ts").then(console.log, console.error);
```
More sample codes can be found in [GitHub](https://github.com/InCar/ali-mns/tree/master/test).

Expand Down Expand Up @@ -299,7 +303,7 @@ keyId: String, ali key id.

keySecret: String, ali key secret.
```javascript
var AliMNS = require("ali-mns");
var AliMNS = require("ali-mns-ts");
var account = new AliMNS.Account("<your-owner-id>", "<your-key-id>", "<your-key-secret>");
```
The account object is usually passed as an argument for other class such as *MNS*, *MQ*
Expand Down Expand Up @@ -380,7 +384,7 @@ If it is string, it can be "hangzhou", "beijing" or any Chinese datacenter city
If it is Region, it allows you to specify data center other than in China.
Default is "hangzhou". It can also be internal or vpc address "hangzhou-internal", "beijing-internal" or "qingdao-internal-vpc".
```javascript
var AliMNS = require("ali-mns");
var AliMNS = require("ali-mns-ts");
var account = new AliMNS.Account("<your-account-id>", "<your-key-id>", "<your-key-secret>");
var mns = new AliMNS.MNS(account, "hangzhou");
// or
Expand Down Expand Up @@ -456,7 +460,7 @@ If it is string, it can be "hangzhou", "beijing" or any Chinese datacenter city
If it is Region, it allows you to specify data center other than in China.
Default is "hangzhou". It can also be internal or vpc address "hangzhou-internal", "beijing-internal" or "qingdao-internal-vpc".
```javascript
var AliMNS = require("ali-mns");
var AliMNS = require("ali-mns-ts");
var account = new AliMNS.Account("<your-account-id>", "<your-key-id>", "<your-key-secret>");
var mq = new AliMNS.MQ(account, "hangzhou");
// or
Expand All @@ -483,7 +487,7 @@ priority: number, optional. 1(lowest)~16(highest), default is 8.
delaySeconds: number, optional. How many seconds will the messages be visible after sent. 0~604800(7days), default is 0.
This argument is prior to the options.DelaySeconds in attributes of message queue.
```javascript
mq.sendP("Hello Ali-MNS", 8, 0).then(console.log, console.error);
mq.sendP("Hello ali-mns-ts", 8, 0).then(console.log, console.error);
```

## mq.getRecvTolerance() & mq.setRecvTolerance(value:number)
Expand Down Expand Up @@ -692,7 +696,7 @@ All other arguments are same as *mq.notifyRecv*.
The class `MNSTopic` extends class `MNS` for providing features in topic model.
All methods in `MNS` class are also available in `MNSTopic`.
```javascript
var AliMNS = require("ali-mns");
var AliMNS = require("ali-mns-ts");
var account = new AliMNS.Account("<your-account-id>", "<your-key-id>", "<your-key-secret>");
var mns = new AliMNS.MNSTopic(account, "shenzhen");
// or
Expand Down Expand Up @@ -737,7 +741,7 @@ If it is string, it can be "hangzhou", "beijing" or any Chinese datacenter city
If it is Region, it allows you to specify data center other than in China.
Default is "hangzhou". It can also be internal or vpc address "hangzhou-internal", "beijing-internal" or "qingdao-internal-vpc".
```javascript
var AliMNS = require("ali-mns");
var AliMNS = require("ali-mns-ts");
var account = new AliMNS.Account("<your-account-id>", "<your-key-id>", "<your-key-secret>");
var topic = new AliMNS.Topic("t11", account, "shenzhen");
// or
Expand Down Expand Up @@ -827,7 +831,7 @@ Set options to `{ forever: true }` will let http(s) channel *KeepAive*.
# Subscription(name:string, topic:Topic)
Operate a subscription.
```javascript
var AliMNS = require("ali-mns");
var AliMNS = require("ali-mns-ts");
var account = new AliMNS.Account("<your-account-id>", "<your-key-id>", "<your-key-secret>");
var topic = new AliMNS.Topic("t11", account, "shenzhen");
var subscription = new AliMNS.Subscription("s12", topic);
Expand Down Expand Up @@ -869,7 +873,7 @@ AliMNS.Subscription.NotifyContentFormat.SIMPLIFIED : "SIMPLIFIED"
[More about NotifyContentFormat[zh-Hans]](https://help.aliyun.com/document_detail/mns/api_reference/concepts/NotifyContentFormat.html?spm=5176.docmns/api_reference/concepts/NotifyStrategy.6.142.kWiFyy)

# DEBUG Trace
Set the environment variable **DEBUG** to "ali-mns" to enable the debug trace output.
Set the environment variable **DEBUG** to "ali-mns-ts" to enable the debug trace output.
```SHELL
# linux bash
export DEBUG=ali-mns
Expand All @@ -889,7 +893,7 @@ var AliMQS = require('ali-mns');
Ali-Yun upgrade their account system, and recommend to use the newer account id instead of owner id.
But the old owner id is still available for now.
```javascript
var AliMQS = require("ali-mns");
var AliMQS = require("ali-mns-ts");
// var account = new AliMNS.Account("hl35yqoedp", "<your-key-id>", "<your-key-secret>");
var account = new AliMNS.Account("1786090012649663", "<your-key-id>", "<your-key-secret>");
```
Expand Down Expand Up @@ -944,14 +948,14 @@ You can check [code](https://github.com/InCar/ali-mns/blob/master/ts/GA.ts#L28)

You can always disable data collection as you wish.
```javascript
var AliMNS = require("ali-mns");
var AliMNS = require("ali-mns-ts");
var account = new AliMNS.Account("<your-account-id>", "<your-key-id>", "<your-key-secret>");

// Disable google analytics data collection
account.setGA(false);

var mq = new AliMNS.MQ("<your-mq-name>", account, "hangzhou");
mq.sendP("Hello ali-mns").then(console.log, console.error);
mq.sendP("Hello ali-mns-ts").then(console.log, console.error);
```

# License
Expand Down
39 changes: 0 additions & 39 deletions gulpfile.js

This file was deleted.

Loading