mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
log server errors in browser
added uid to posts
This commit is contained in:
12
.project
Normal file
12
.project
Normal file
@@ -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>
|
||||||
8
app.js
8
app.js
@@ -17,6 +17,12 @@ global.modules = modules;
|
|||||||
// global.uid = 1;
|
// 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) {
|
(function(config) {
|
||||||
config['ROOT_DIRECTORY'] = __dirname;
|
config['ROOT_DIRECTORY'] = __dirname;
|
||||||
@@ -25,6 +31,6 @@ global.modules = modules;
|
|||||||
// modules.webserver.init();
|
// modules.webserver.init();
|
||||||
modules.websockets.init();
|
modules.websockets.init();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}(global.configuration));
|
}(global.configuration));
|
||||||
@@ -18,6 +18,10 @@ var socket,
|
|||||||
socket.on('event:alert', function(data) {
|
socket.on('event:alert', function(data) {
|
||||||
app.alert(data);
|
app.alert(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('event:consolelog', function(data) {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
async: false
|
async: false
|
||||||
|
|
||||||
|
|||||||
10
src/posts.js
10
src/posts.js
@@ -62,13 +62,15 @@ var RDB = require('./redis.js');
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Posts.create = function(content, callback) {
|
Posts.create = function(uid, content, callback) {
|
||||||
if (global.uid === null) return;
|
console.log("global uid "+uid);
|
||||||
|
|
||||||
|
if (uid === null) return;
|
||||||
|
|
||||||
RDB.incr('global:next_post_id', function(pid) {
|
RDB.incr('global:next_post_id', function(pid) {
|
||||||
// Posts Info
|
// Posts Info
|
||||||
RDB.set('pid:' + pid + ':content', content);
|
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());
|
RDB.set('pid:' + pid + ':timestamp', new Date().getTime());
|
||||||
|
|
||||||
// User Details - move this out later
|
// User Details - move this out later
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ var RDB = require('./redis.js'),
|
|||||||
RDB.set('topic:slug:' + slug + ':tid', tid);
|
RDB.set('topic:slug:' + slug + ':tid', tid);
|
||||||
|
|
||||||
// Posts
|
// Posts
|
||||||
posts.create(content, function(pid) {
|
posts.create(uid, content, function(pid) {
|
||||||
RDB.lpush('tid:' + tid + ':posts', pid);
|
RDB.lpush('tid:' + tid + ':posts', pid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user