forked from NodeBB/NodeBB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor abit adding error checking to missing parts
- Loading branch information
1 parent
411ba35
commit 84fa704
Showing
5 changed files
with
96 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,76 @@ | ||
|
||
var user = require('./../user'), | ||
categories = require('./../categories'), | ||
topics = require('./../topics'), | ||
posts = require('./../posts'); | ||
|
||
|
||
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) { | ||
topics.getTopicData(req.params.tid, function (data) { | ||
if (data) { | ||
res.send(data); | ||
} else { | ||
res.send(404, "Topic doesn't exist!"); | ||
} | ||
}); | ||
app.namespace('/debug', function() { | ||
|
||
app.get('/uid/:uid', function (req, res) { | ||
|
||
if (!req.params.uid) | ||
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) { | ||
if (data) { | ||
res.send(data); | ||
} else { | ||
res.send(404, "Post doesn't exist!"); | ||
} | ||
}); | ||
|
||
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('/prune', function(req, res) { | ||
var Notifications = require('../notifications'); | ||
app.get('/tid/:tid', function (req, res) { | ||
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() { | ||
console.log('done'); | ||
}); | ||
res.send(); | ||
app.get('/pid/:pid', function (req, res) { | ||
posts.getPostData(req.params.pid, function (err, data) { | ||
if (data) { | ||
res.send(data); | ||
} else { | ||
res.send(404, "Post doesn't exist!"); | ||
} | ||
}); | ||
}); | ||
|
||
app.get('/uuidtest', function(req, res) { | ||
var Utils = require('../../public/src/utils.js'); | ||
app.get('/prune', function(req, res) { | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters