YUKI Hiroshi
null+****@clear*****
Thu Feb 7 16:50:19 JST 2013
YUKI Hiroshi 2013-02-07 16:50:19 +0900 (Thu, 07 Feb 2013) New Revision: e5bfa30039b025ef181bdf935201f83746714bc3 https://github.com/groonga/express-kotoumi/commit/e5bfa30039b025ef181bdf935201f83746714bc3 Log: Update plugin system based on new model systems Modified files: lib/frontend/default-commands/socket.io.js lib/frontend/rest-adaptor.js lib/frontend/socket.io-adaptor.js Modified: lib/frontend/default-commands/socket.io.js (+1 -1) =================================================================== --- lib/frontend/default-commands/socket.io.js 2013-02-07 16:49:41 +0900 (52b5fb4) +++ lib/frontend/default-commands/socket.io.js 2013-02-07 16:50:19 +0900 (104795f) @@ -2,7 +2,7 @@ var model = require('../../model'); module.exports = { // 'status': {}, - 'search': new model.RequestResponse()//, + 'search': new model.SocketRequestResponse()//, // 'createtable': {}, // 'removetable': {}, // 'createcolumn': {}, Modified: lib/frontend/rest-adaptor.js (+3 -5) =================================================================== --- lib/frontend/rest-adaptor.js 2013-02-07 16:49:41 +0900 (a196f2f) +++ lib/frontend/rest-adaptor.js 2013-02-07 16:50:19 +0900 (ee50e83) @@ -1,3 +1,4 @@ +var model = require('../model'); var defaultCommands = require('./default-commands/rest'); function createHandler(params) { @@ -58,12 +59,9 @@ exports.register = function(application, params) { var commandSets = [defaultCommands].concat(params.plugins || []); var unifiedCommandSet = {}; commandSets.forEach(function(commandSet) { - if (typeof commandSet == 'string') - commandSet = require(commandSet); - Object.keys(commandSet).forEach(function(command) { var definition = commandSet[command]; - if (!definition.path) // ignore non-REST command + if (!model.isA(definition, model.REST)) return; unifiedCommandSet[command] = definition; }); @@ -72,7 +70,7 @@ exports.register = function(application, params) { var registeredCommands = []; Object.keys(unifiedCommandSet).forEach(function(command) { var definition = unifiedCommandSet[command]; - if (!definition.path) // ignore not a command definition + if (!model.isA(definition, model.REST)) return; var method = getRegisterationMethod(definition.method); var handler = createHandler({ Modified: lib/frontend/socket.io-adaptor.js (+4 -12) =================================================================== --- lib/frontend/socket.io-adaptor.js 2013-02-07 16:49:41 +0900 (24c563f) +++ lib/frontend/socket.io-adaptor.js 2013-02-07 16:50:19 +0900 (ab25b8e) @@ -34,8 +34,8 @@ exports.register = function(application, server, params) { return (function(data) { var commandDefinition = unifiedCommandSet[commandName]; - if (commandDefinition.requestBuilder) - data = commandDefinition.requestBuilder(data); + if (commandDefinition.toBackend) + commandName, data = commandDefinition.toBackend(commandName, data); connection.emitMessage(commandName, data, callback, options); }); @@ -49,15 +49,10 @@ exports.register = function(application, server, params) { var resultTypeMatch = envelope.type.match(/^(.+)\.result$/); if (resultTypeMatch && unifiedCommandSet[resultTypeMatch[1]]) { var command = unifiedCommandSet[resultTypeMatch[1]]; - if (command.responseBuilder) - data = command.responseBuilder(envelope); - if (command.responseEvent) - event = command.responseEvent; + if (command.toClient) + event, data = command.toClient(envelope.type, envelope.body); } - if (!data) - data = sanitizeBackendMessage(envelope); - socket.emit(event, data); }); } @@ -71,9 +66,6 @@ exports.register = function(application, server, params) { var commandSets = [defaultCommands].concat(params.plugins || []); var unifiedCommandSet = {}; commandSets.forEach(function(commandSet) { - if (typeof commandSet == 'string') - commandSet = require(commandSet); - Object.keys(commandSet).forEach(function(command) { var definition = commandSet[command]; if (!model.isA(definition, model.SocketCommand)) -------------- next part -------------- HTML����������������������������... 다운로드