#更新所有套件(這樣跑很可怕XD)
npm update
#更新單一套件
npm install express-validator@5.3.1 --save-dev






npm install firebase-admin --save
var admin = require('firebase-admin');
var serviceAccount = require('path/to/serviceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://.firebaseio.com'
});
// The topic name can be optionally prefixed with "/topics/".
var topic = 'highScores';
// See documentation on defining a message payload.
var message = {
data: {
score: '850',
time: '2:45'
},
topic: topic};
// Send a message to devices subscribed to the provided topic.
admin.messaging().send(message)
.then((response) => {
// Response is a message ID string.
console.log('Successfully sent message:', response);
})
.catch((error) => {
console.log('Error sending message:', error);
});
admin.messaging().send(message, dryRun)
// Define a condition which will send to devices which are subscribed
// to either the Google stock or the tech industry topics.
var condition = "'stock-GOOG' in topics || 'industry-tech' in topics";
// See documentation on defining a message payload.
var message = {
notification: {
title: '$GOOG up 1.43% on the day',
body: '$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.'
},
condition: condition};
// Send a message to devices subscribed to the combination of topics
// specified by the provided condition.
admin.messaging().send(message)
.then((response) => {
// Response is a message ID string.
console.log('Successfully sent message:', response);
})
.catch((error) => {
console.log('Error sending message:', error);
});
| 参数 | 说明 |
|---|---|
data | 键值对映射,其中所有键和值都是字符串。 |
notification | 一个包含 title 和 body 字段的对象。 |
android | 一个由 Android 消息专用字段组成的对象。要了解详情,请参阅 Android 专用字段。 |
apns | 一个由 Apple 推送通知服务 (APNS) 专用字段组成的对象。要了解详情,请参阅 APNS 专用字段。 |
webpush | 一个由 WebPush 协议专用字段组成的对象。要了解详情,请参阅 WebPush 专用字段。 |
token | 一个用于标识消息的收件人设备的注册令牌。 |
topic | 要将消息发送至的主题名称。该主题名称不能包含 /topics/ 前缀。 |
condition | 发送消息时所依据的条件,例如 "foo" in topics && "bar" in topics |
var message = {
notification: {
title: '$GOOG up 1.43% on the day',
body: '$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.',
},
android: {
ttl: 3600 * 1000,
notification: {
icon: 'stock_ticker_update',
color: '#f45342',
},
},
apns: {
payload: {
aps: {
badge: 42,
},
},
},
topic: 'industry-tech'
};
angular.module('module2', ['ui.router'])
.run(['$state', function($state){
var state = $state.get('先前的路由命名');
state.templateUrl = '新的樣版';
}]);
export NODE_ENV=production
SET NODE_ENV=production
NODE_ENV=production node app.js
process.env.NODE_ENV = 'production';
https://stackoverflow.com/questions/9198310/how-to-set-node-env-to-production-development-in-os-x