Files
NodeBB/src/routes/debug.js

95 lines
2.2 KiB
JavaScript
Raw Normal View History

"use strict";
2014-07-02 14:07:08 -04:00
var express = require('express'),
user = require('./../user'),
categories = require('./../categories'),
topics = require('./../topics'),
posts = require('./../posts');
module.exports = function(app, middleware, controllers) {
2014-07-02 14:07:08 -04:00
var router = express.Router();
2014-07-02 15:44:09 -04:00
app.use('/debug', router);
2014-07-02 14:07:08 -04:00
router.get('/uid/:uid', function (req, res) {
if (!req.params.uid) {
return res.redirect('/404');
}
2014-07-02 14:07:08 -04:00
user.getUserData(req.params.uid, function (err, data) {
if (data) {
res.send(data);
} else {
res.json(404, {
error: "User doesn't exist!"
});
}
});
2014-07-02 14:07:08 -04:00
});
2014-07-02 14:07:08 -04:00
router.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!");
}
});
2014-07-02 14:07:08 -04:00
});
2014-07-02 14:07:08 -04:00
router.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!");
}
});
2014-07-02 14:07:08 -04:00
});
2014-07-02 14:07:08 -04:00
router.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!");
}
});
});
2014-07-02 14:07:08 -04:00
router.get('/test', function(req, res) {
2014-07-28 15:52:33 -04:00
//res.redirect('404');
var notifications = require('../notifications');
var nconf = require('nconf');
var username = 'julian';
var topicTitle = 'testing tags';
var topicSlug = '1748/testing-tags';
var postIndex = 1;
var tid = 1748;
var fromUid = 2;
notifications.create({
bodyShort: '[[notifications:user_posted_to, ' + username + ', ' + topicTitle + ']]',
bodyLong: 'asdasd khajsdhakhdakj hdkash dakhdakjdhakjs',
path: nconf.get('relative_path') + '/topic/' + topicSlug + '/' + postIndex,
2014-07-28 17:50:49 -04:00
uniqueId: 'topic:' + tid + ':uid:' + fromUid,
2014-07-28 16:11:26 -04:00
tid: tid,
2014-07-28 15:52:33 -04:00
from: fromUid
}, function(err, nid) {
notifications.push(nid, [1]);
res.json('done');
});
2014-07-02 14:07:08 -04:00
});
2014-07-28 15:52:33 -04:00
router.get('/dailyunread', function(req, res) {
//var userNotifs = require('./user');
user.notifications.getDailyUnread(1, function(err, data) {
if (err) {
res.json(500, err.message);
}
res.json(data);
});
})
2014-04-10 20:31:57 +01:00
};