Comparing version 0.20.0 to 0.21.0
@@ -0,1 +1,18 @@ | ||
## 0.21.0 (2017-01-11) | ||
### Features | ||
- Call includeme in index.js for user cloud code | ||
- Add support for LOAD_MODULES and includeme (#155) | ||
- Accept bundle name when register device (SkygearIO/skygear-server#239) | ||
### Bug Fixes | ||
- Fix unable to start when LOAD_MODULES is not set | ||
This happens because when LOAD_MODULES is not set the parsed module | ||
list will be an array with an empty string. This causes configModule | ||
to be called with an empty string. | ||
## 0.20.0 (2016-12-20) | ||
@@ -2,0 +19,0 @@ |
@@ -15,2 +15,4 @@ 'use strict'; | ||
var _cloud = require('./cloud'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -24,3 +26,3 @@ | ||
if (cmd === '--help') { | ||
process.stdout.write('\n Usage: skygear-node <file>\n\n file will default to index.js if not provided.\n\n skygear-node are configured by ENVVAR:\n - SKYGEAR_ADDRESS: Binds to this socket for skygear\n - SKYGEAR_ENDPOINT: Send to this address for skygear handlers\n - API_KEY: API Key of the application\n - MASTER_KEY: Master Key of the application\n - APP_NAME: Application name of the skygear daemon\n - LOG_LEVEL: Log level\n - HTTP: Trigger http web server\n - HTTP_ADDR: Address where htp web server listen to\n - DEBUG: Enable debugging features\n - SERVE_STATIC_ASSETS: Enable to serve static asset from plugin process\n - PUBSUB_URL: The URL of the pubsub server, should start with ws://\n or wss:// and include the path\n '); | ||
process.stdout.write('\n Usage: skygear-node <file>\n\n file will default to index.js if not provided.\n\n skygear-node are configured by ENVVAR:\n - SKYGEAR_ADDRESS: Binds to this socket for skygear\n - SKYGEAR_ENDPOINT: Send to this address for skygear handlers\n - API_KEY: API Key of the application\n - MASTER_KEY: Master Key of the application\n - APP_NAME: Application name of the skygear daemon\n - LOG_LEVEL: Log level\n - HTTP: Trigger http web server\n - HTTP_ADDR: Address where htp web server listen to\n - DEBUG: Enable debugging features\n - SERVE_STATIC_ASSETS: Enable to serve static asset from plugin process\n - PUBSUB_URL: The URL of the pubsub server, should start with ws://\n or wss:// and include the path\n - LOAD_MODULES: List of comma separated modules to load\n '); | ||
@@ -35,4 +37,10 @@ process.exit(); | ||
_settings.settings.loadModules.forEach(function (moduleName) { | ||
(0, _cloud.configModule)(moduleName); | ||
}); | ||
var codePath = _path2.default.join(process.cwd(), cmd); | ||
require(codePath); | ||
(0, _cloud.configModule)(codePath, { | ||
ignoreWarning: true | ||
}); | ||
@@ -39,0 +47,0 @@ // Register the static asset as handler if configured so |
@@ -36,2 +36,3 @@ 'use strict'; | ||
exports.staticAsset = staticAsset; | ||
exports.configModule = configModule; | ||
@@ -70,3 +71,3 @@ var _pg = require('./pg'); | ||
var _settings2 = require('./settings'); | ||
var _settings3 = require('./settings'); | ||
@@ -417,7 +418,31 @@ var _crypto = require('crypto'); | ||
/** | ||
* Import and config the cloud code plugin module. | ||
* | ||
* This function will load the specified module by name using the `require` | ||
* function. The specified module must exists or an error is thrown. | ||
* | ||
* It is expected that the module will exports a function called `includeme`. | ||
* This function will also call the `includeme` function to config the module. | ||
*/ | ||
function configModule(moduleName, options) { | ||
var _ref = options || {}, | ||
ignoreWarning = _ref.ignoreWarning; | ||
var _require = require(moduleName), | ||
includeme = _require.includeme; | ||
if (includeme !== undefined) { | ||
var _settings2 = {}; | ||
includeme(module.exports, _settings2); | ||
} else if (ignoreWarning !== true) { | ||
console.warn('The ' + moduleName + ' module does not export the includeme' + ' function. This function is required to config the module.'); | ||
} | ||
} | ||
var skyconfig = exports.skyconfig = _skyconfig3.default; | ||
var pool = exports.pool = _pg.pool; | ||
var settings = exports.settings = _settings2.settings; | ||
var settings = exports.settings = _settings3.settings; | ||
var CloudCodeContainer = exports.CloudCodeContainer = _container2.default; | ||
var ErrorCodes = exports.ErrorCodes = _error.ErrorCodes; | ||
var SkygearError = exports.SkygearError = _error.SkygearError; |
@@ -42,2 +42,30 @@ 'use strict'; | ||
function loadModuleSettings() { | ||
var modulesList = process.env.LOAD_MODULES || ''; | ||
if (modulesList === '') { | ||
return []; | ||
} | ||
var modules = []; | ||
if (modulesList.indexOf(':') >= 0) { | ||
modules = modulesList.split(':'); | ||
} else if (modulesList.indexOf(',') >= 0) { | ||
modules = modulesList.split(','); | ||
} else { | ||
modules = modulesList.split(' '); | ||
} | ||
var loadingModules = []; | ||
modules.forEach(function (moduleName) { | ||
if (moduleName.indexOf('~') === -1) { | ||
loadingModules.push(moduleName); | ||
} else if (moduleName.substring(moduleName.length - 3) === '~js') { | ||
loadingModules.push(moduleName.substring(0, moduleName.length - 3)); | ||
} | ||
}); | ||
return loadingModules; | ||
} | ||
var settings = exports.settings = { | ||
@@ -56,3 +84,4 @@ skygearAddress: process.env.SKYGEAR_ADDRESS || 'tcp://127.0.0.1:6666', | ||
forceAsset: process.env.FORCE_ASSET || false, | ||
databaseURL: process.env.DATABASE_URL || 'postgres://postgres@db/postgres?sslmode=disable' | ||
databaseURL: process.env.DATABASE_URL || 'postgres://postgres@db/postgres?sslmode=disable', | ||
loadModules: loadModuleSettings() | ||
}; |
@@ -417,5 +417,15 @@ 'use strict'; | ||
} | ||
/** | ||
* You can register your device for receiving push notifications. | ||
* | ||
* @param {string} token - The device token | ||
* @param {string} type - The device type (either 'ios' or 'android') | ||
* @param {string} topic - The device topic, refer to application bundle | ||
* identifier on iOS and application package name on Android. | ||
**/ | ||
}, { | ||
key: 'registerDevice', | ||
value: function registerDevice(token, type) { | ||
value: function registerDevice(token, type, topic) { | ||
if (!token) { | ||
@@ -447,2 +457,3 @@ throw new Error('Token cannot be empty'); | ||
id: deviceID, | ||
topic: topic, | ||
device_token: token | ||
@@ -449,0 +460,0 @@ }).then(function (body) { |
{ | ||
"name": "skygear", | ||
"version": "0.20.0", | ||
"version": "0.21.0", | ||
"description": "JS SDK of Skygear services", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/SkygearIO/skygear-SDK-JS", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
2201394
25452