refactor abit adding error checking to missing parts
parent
411ba3542c
commit
84fa704b25
@ -1,50 +1,76 @@
|
|||||||
|
|
||||||
|
var user = require('./../user'),
|
||||||
|
categories = require('./../categories'),
|
||||||
|
topics = require('./../topics'),
|
||||||
|
posts = require('./../posts');
|
||||||
|
|
||||||
|
|
||||||
var DebugRoute = function(app) {
|
var DebugRoute = function(app) {
|
||||||
app.namespace('/debug', function() {
|
|
||||||
app.get('/cid/:cid', function (req, res) {
|
|
||||||
categories.getCategoryData(req.params.cid, function (err, data) {
|
|
||||||
if (data) {
|
|
||||||
res.send(data);
|
|
||||||
} else {
|
|
||||||
res.send(404, "Category doesn't exist!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/tid/:tid', function (req, res) {
|
app.namespace('/debug', function() {
|
||||||
topics.getTopicData(req.params.tid, function (data) {
|
|
||||||
if (data) {
|
app.get('/uid/:uid', function (req, res) {
|
||||||
res.send(data);
|
|
||||||
} else {
|
if (!req.params.uid)
|
||||||
res.send(404, "Topic doesn't exist!");
|
return res.redirect('/404');
|
||||||
}
|
|
||||||
});
|
user.getUserData(req.params.uid, function (err, data) {
|
||||||
|
if (data) {
|
||||||
|
res.send(data);
|
||||||
|
} else {
|
||||||
|
res.json(404, {
|
||||||
|
error: "User doesn't exist!"
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/pid/:pid', function (req, res) {
|
|
||||||
posts.getPostData(req.params.pid, function (data) {
|
app.get('/cid/:cid', function (req, res) {
|
||||||
if (data) {
|
categories.getCategoryData(req.params.cid, function (err, data) {
|
||||||
res.send(data);
|
if (data) {
|
||||||
} else {
|
res.send(data);
|
||||||
res.send(404, "Post doesn't exist!");
|
} else {
|
||||||
}
|
res.send(404, "Category doesn't exist!");
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/prune', function(req, res) {
|
app.get('/tid/:tid', function (req, res) {
|
||||||
var Notifications = require('../notifications');
|
topics.getTopicData(req.params.tid, function (err, data) {
|
||||||
|
if (data) {
|
||||||
|
res.send(data);
|
||||||
|
} else {
|
||||||
|
res.send(404, "Topic doesn't exist!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Notifications.prune(new Date(), function() {
|
app.get('/pid/:pid', function (req, res) {
|
||||||
console.log('done');
|
posts.getPostData(req.params.pid, function (err, data) {
|
||||||
});
|
if (data) {
|
||||||
res.send();
|
res.send(data);
|
||||||
|
} else {
|
||||||
|
res.send(404, "Post doesn't exist!");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/uuidtest', function(req, res) {
|
app.get('/prune', function(req, res) {
|
||||||
var Utils = require('../../public/src/utils.js');
|
var Notifications = require('../notifications');
|
||||||
|
|
||||||
res.send(Utils.generateUUID());
|
Notifications.prune(new Date(), function() {
|
||||||
|
console.log('done');
|
||||||
});
|
});
|
||||||
|
res.send();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/uuidtest', function(req, res) {
|
||||||
|
var Utils = require('../../public/src/utils.js');
|
||||||
|
|
||||||
|
res.send(Utils.generateUUID());
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = DebugRoute;
|
module.exports = DebugRoute;
|
Loading…
Reference in New Issue