var config = require('./container-config.json'); // Get our service configuration.var data = require(config.data.type); // Load our data source plugin ('npm install mysql' for mysql).var service = require(config.service.type); // Load our service plugin ('http' is built-in to node).var processor = require('./app.js'); // Load our processor (the code you write).
var connection = data.createConnection({ host: config.data.host, user: config.data.user, password: config.data.pass, database: config.data.name });var server = service.createServer(processor);connection.connect();server.listen(config.service.port, function() { console.log("%s service listening on port %s", config.service.type, config.service.port); });
app.js.…(为协议无关和数据源无关服务提供支持的代码)
module.exports = function(request, response){response.end('Responding to: ' + request.url);}