Comparing version 0.0.16 to 0.0.17
@@ -5,3 +5,9 @@ module.exports = { | ||
plugins: { | ||
require: ["db", "db.mongodb"] // add "db.mysql" to use mysql | ||
require: [ | ||
"db", | ||
"db.mongodb", | ||
// "db.mysql", | ||
// "impress.mail", | ||
// "impress.geoip" | ||
] | ||
}, | ||
@@ -48,3 +54,3 @@ | ||
// Mail configuration | ||
smtp: { | ||
mail: { | ||
enabled: false, // enable or disable smtp transport | ||
@@ -61,10 +67,2 @@ robot: "Robot name <robotname@gmail.com>", | ||
// Mail configuration | ||
smtp: { | ||
options: { | ||
host: "212.111.203.3" | ||
} | ||
}, | ||
// Cluster configuraton | ||
@@ -71,0 +69,0 @@ cluster: { |
@@ -0,1 +1,8 @@ | ||
0.0.17 / 2010-07-01 | ||
================== | ||
* Added interprocess SSE routing via IPC (worker sends it to master and master propagates to all other workers) | ||
* Added package "geoip-lite" as plugin "impress.geoip": geoData = impress.geoip.lookup(req.connection.remoteAddress); | ||
* Package "nodemailer" moved to plugin "impress.mail" | ||
0.0.16 / 2010-06-30 | ||
@@ -2,0 +9,0 @@ ================== |
@@ -21,3 +21,2 @@ (function(impress) { | ||
impress.mkdirp = require('mkdirp'); | ||
impress.nodemailer = require("nodemailer"); | ||
impress.zlib = require('zlib'); | ||
@@ -290,7 +289,2 @@ | ||
// Initialize SMTP transport | ||
if (impress.config.smtp && impress.config.smtp.enabled) { | ||
impress.smtp = impress.nodemailer.createTransport("SMTP",impress.config.smtp.options); | ||
} | ||
if(impress.config.databases) impress.openDatabases(callback); | ||
@@ -320,10 +314,18 @@ | ||
process.on('message', function(message, socket) { | ||
if (message.name !== 'impress:socket') return; | ||
var servers = impress.config.servers; | ||
for (var serverName in servers) { | ||
var server = servers[serverName]; | ||
if (server.address == message.address && server.port == message.port) { | ||
socket.server = server.listener; | ||
server.listener.emit('connection', socket); | ||
if (message.name == 'impress:socket') { | ||
var servers = impress.config.servers; | ||
for (var serverName in servers) { | ||
var server = servers[serverName]; | ||
if (server.address == message.address && server.port == message.port) { | ||
socket.server = server.listener; | ||
server.listener.emit('connection', socket); | ||
} | ||
} | ||
} else if (message.name == 'impress:sse') { | ||
// Retranslated SSE from master to worker | ||
//console.dir({workerRetranslated:{message:message, id:impress.workerId}}); | ||
if (message.user) impress.sse.userEvent(message.user, message.eventName, message.data, true); | ||
else if (message.channel) impress.sse.channelEvent(message.channel, message.eventName, message.data, true); | ||
else if (message.global) impress.sse.globalEvent(message.eventName, message.data, true); | ||
} | ||
@@ -356,5 +358,2 @@ }); | ||
// Cloase smtp transport | ||
if (impress.smtp) impress.smtp.close(); | ||
// Close log files | ||
@@ -386,2 +385,13 @@ if (impress.log.fdAccess) { | ||
}); | ||
// Initialize IPC for interprocess SSE routing, from worker to master | ||
worker.on('message', function(msg) { | ||
// propagate to all workers except of original sender | ||
for (var id in impress.workers) { | ||
if (id != workerId) { | ||
//console.dir({masterPropagate:{workerId:id,msg:msg}}); | ||
impress.workers[id].send(msg); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -786,3 +796,3 @@ | ||
if (userId && res.sse && res.sse.channel) { | ||
console.log('SSE: incoming connection'); | ||
//console.log('SSE: incoming connection'); | ||
res.writeHead(200, { | ||
@@ -811,3 +821,3 @@ 'Content-Type': impress.mimeTypes['sse'], | ||
req.on('close', function() { | ||
console.log('SSE: socket close'); | ||
//console.log('SSE: socket close'); | ||
impress.sse.statistics.active--; | ||
@@ -818,3 +828,3 @@ impress.sse.statistics.disconnected++; | ||
req.on('error', function(err) { | ||
console.log('SSE: socket error'); | ||
//console.log('SSE: socket error'); | ||
impress.sse.statistics.active--; | ||
@@ -826,3 +836,3 @@ impress.sse.statistics.disconnected++; | ||
req.on('timeout',function() { | ||
console.log('SSE: timeout'); | ||
//console.log('SSE: timeout'); | ||
impress.sse.statistics.active--; | ||
@@ -834,3 +844,3 @@ impress.sse.statistics.disconnected++; | ||
req.socket.on('timeout',function() { | ||
console.log('SSE: socket timeout'); | ||
//console.log('SSE: socket timeout'); | ||
impress.sse.statistics.active--; | ||
@@ -845,7 +855,16 @@ impress.sse.statistics.disconnected++; | ||
// | ||
impress.sse.userEvent = function(userId, eventName, data) { | ||
impress.sse.userEvent = function(userId, eventName, data, isRetranslation) { | ||
var packet = 'event: '+eventName+'\ndata: '+JSON.stringify(data)+'\n\n', | ||
buf = new Buffer(packet, 'utf8'), | ||
isRetranslation = isRetranslation || false; | ||
//console.dir({userEvent:{channel:channel, eventName:eventName}}); | ||
if (impress.cluster.isWorker && !isRetranslation) process.send({ | ||
name: 'impress:sse', | ||
user: userId, | ||
event: eventName, | ||
data: data | ||
}); | ||
if (impress.users[userId] && impress.users[userId].sse) { | ||
var packet = 'event: '+eventName+'\ndata: '+JSON.stringify(data)+'\n\n', | ||
buf = new Buffer(packet, 'utf8'); | ||
//console.dir({userEvent:{channel:channel, eventName:eventName}}); | ||
for (var i in impress.users[userId].sse) { | ||
@@ -860,8 +879,19 @@ //console.dir({i:i}); | ||
// | ||
impress.sse.channelEvent = function(channel, eventName, data) { | ||
if (impress.sse.channels[channel]) { | ||
//console.dir({channelEvent:{channel:channel, eventName:eventName}}); | ||
var packet = 'event: '+eventName+'\ndata: '+JSON.stringify(data)+'\n\n', | ||
buf = new Buffer(packet, 'utf8'), | ||
users = impress.sse.channels[channel]; | ||
impress.sse.channelEvent = function(channel, eventName, data, isRetranslation) { | ||
//console.dir({channelEvent:{channel:channel, eventName:eventName, isWorker: impress.cluster.isWorker}}); | ||
var packet = 'event: '+eventName+'\ndata: '+JSON.stringify(data)+'\n\n', | ||
buf = new Buffer(packet, 'utf8'), | ||
isRetranslation = isRetranslation || false; | ||
//console.dir({isRetranslation:isRetranslation}); | ||
if (impress.cluster.isWorker && !isRetranslation) process.send({ | ||
name: 'impress:sse', | ||
channel: channel, | ||
event: eventName, | ||
data: data | ||
}); | ||
if (impress.sse.channels[channel], isRetranslation) { | ||
var users = impress.sse.channels[channel]; | ||
for (var j in users) { | ||
@@ -884,5 +914,13 @@ var userId = users[j]; | ||
var packet = 'event: '+eventName+'\ndata: '+JSON.stringify(data)+'\n\n', | ||
buf = new Buffer(packet, 'utf8'); | ||
buf = new Buffer(packet, 'utf8'), | ||
isRetranslation = isRetranslation || false; | ||
//console.dir({globalEvent:{eventName:eventName}}); | ||
//console.dir({users:impress.users}); | ||
if (impress.cluster.isWorker && !isRetranslation) process.send({ | ||
name: 'impress:sse', | ||
global: true, | ||
event: eventName, | ||
data: data | ||
}); | ||
for (var channelName in impress.sse.channels) { | ||
@@ -1313,18 +1351,2 @@ //console.dir({channelName:channelName}); | ||
impress.sendPassword = function(to) { | ||
if (impress.smtp) impress.smtp.sendMail({ | ||
from: impress.config.smtp.robot, | ||
to: to, | ||
subject: "Hello", | ||
text: "Hello world !", | ||
html: "<b>Hello world !</b>" | ||
}, function(error, response) { | ||
if (error) { | ||
console.log(error); | ||
} else { | ||
console.log("Message sent: " + response.message); | ||
} | ||
}); | ||
} | ||
} (global.impress = global.impress || {})); |
{ | ||
"name": "impress", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -45,3 +45,4 @@ "description": "Impressive totalitarian style multipurpose web application server. All decisions are made. Ready for applied development.", | ||
"mysql": "2.0.x", | ||
"nodemailer": "0.4.x" | ||
"nodemailer": "0.4.x", | ||
"geoip-lite": "1.0.x" | ||
}, | ||
@@ -48,0 +49,0 @@ "engines": { |
@@ -7,2 +7,4 @@ ![impress logo](http://habrastorage.org/storage2/c1e/1b7/190/c1e1b7190c8c6685a34d6584e936c4c9.png) | ||
The main difference from others that Impress core is monolithic and its approach is to make all in one solution with high code coupling for obligatory things and leave not obligatory to be integrated by applied developers optionally. High coupling in core gives us advantages in performance and code simplicity. For example, why we should implement static files serving or memory caching as a plugin while no one application will omit that. | ||
## Installation | ||
@@ -16,3 +18,3 @@ | ||
- url routing based on file system | ||
- URL routing based on file system | ||
- can hosts multiple sites or applications on one server | ||
@@ -24,3 +26,3 @@ - serving multiple ports, network interfaces, hosts and protocols | ||
- folder monitoring for server-side executable JavaScript changes and template changes | ||
- buil-in authentication and user groups | ||
- built-in authentication and user groups | ||
- sessions and cookies (memory state or persistent sessions with MongoDB) | ||
@@ -37,3 +39,3 @@ - template personalization for user groups | ||
- ip sticky (multiple processes, one master and workers with serving sticky by IP) | ||
- reverse-proxy (routing request to external HTTP server with url-rewriting) | ||
- reverse-proxy (routing request to external HTTP server with URL-rewriting) | ||
- flexible configuration in json file | ||
@@ -46,6 +48,6 @@ - simple logging web requests | ||
1. Copy project template from examples into your project folder | ||
2. Edit config.js file in project folder | ||
3. If you want to store persistent sessions in MongoDB, you need to run setup.js | ||
4. Run command: node server.js | ||
1. Copy project template from examples into your project folder (it contains 3 files and folder "sites" where virtual hosts are) | ||
2. Edit config.js file in project folder (or leave it untouched if you want just to test Impress) | ||
3. If you want to store persistent sessions in MongoDB you need this DBMS installed and you need to run "node setup.js" before starting Impress | ||
4. Run Impress using command "node server.js" | ||
@@ -106,4 +108,9 @@ ## Handler examples and file system url mapping | ||
users: [ | ||
{ name: "vasia", age: 22, emails: ["user1@gmail.com", "user2@gmail.com"] }, | ||
{ name: "dima", age: 32, emails: ["user3@gmail.com", "user4@gmail.com", "user5@gmail.com"] }, | ||
{ | ||
name: "vasia", age: 22, | ||
emails: ["user1@gmail.com", "user2@gmail.com"] | ||
},{ | ||
name: "dima", age: 32, | ||
emails: ["user3@gmail.com", "user4@gmail.com", "user5@gmail.com"] | ||
} | ||
], | ||
@@ -110,0 +117,0 @@ session: JSON.stringify(impress.sessions[req.impress.session]) |
@@ -8,3 +8,2 @@ # TODO | ||
* Add support for file uploads (POST requests) | ||
* Add geoIP lookup | ||
* Add json api example 'auth' for registration, sign in, sign out, recovery password and so on | ||
@@ -18,3 +17,2 @@ * Add examples with web GUI controls | ||
* Make config parameters optional, prosess, route, hosts, etc. | ||
* Send SSE multicast to other processes using IPC | ||
@@ -21,0 +19,0 @@ ## Bugs |
556846
55
12093
180
8
+ Addedgeoip-lite@1.0.x
+ Addedgeoip-lite@1.0.10(transitive)