log server errors in browser

added uid to posts
v1.18.x
Baris Soner Usakli 12 years ago
parent a6cbed94fc
commit 20aa5d439e

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>node-forum</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
<nature>com.aptana.projects.webnature</nature>
</natures>
</projectDescription>

@ -17,6 +17,12 @@ global.modules = modules;
// global.uid = 1;
process.on('uncaughtException', function(err) {
// handle the error safely
console.log("error message "+err);
global.socket.emit('event:consolelog',{type:'uncaughtException',stack:err.stack,error:err.toString()});
});
(function(config) {
config['ROOT_DIRECTORY'] = __dirname;
@ -25,6 +31,6 @@ global.modules = modules;
// modules.webserver.init();
modules.websockets.init();
}(global.configuration));

@ -18,6 +18,10 @@ var socket,
socket.on('event:alert', function(data) {
app.alert(data);
});
socket.on('event:consolelog', function(data) {
console.log(data);
});
},
async: false

@ -62,13 +62,15 @@ var RDB = require('./redis.js');
};
Posts.create = function(content, callback) {
if (global.uid === null) return;
Posts.create = function(uid, content, callback) {
console.log("global uid "+uid);
if (uid === null) return;
RDB.incr('global:next_post_id', function(pid) {
// Posts Info
RDB.set('pid:' + pid + ':content', content);
RDB.set('pid:' + pid + ':uid', global.uid);
RDB.set('pid:' + pid + ':uid', uid);
RDB.set('pid:' + pid + ':timestamp', new Date().getTime());
// User Details - move this out later

@ -137,7 +137,7 @@ var RDB = require('./redis.js'),
RDB.set('topic:slug:' + slug + ':tid', tid);
// Posts
posts.create(content, function(pid) {
posts.create(uid, content, function(pid) {
RDB.lpush('tid:' + tid + ':posts', pid);
});

Loading…
Cancel
Save