Files
NodeBB/src/controllers/admin/errors.js

34 lines
822 B
JavaScript
Raw Normal View History

2016-05-24 22:01:46 -04:00
'use strict';
2016-09-16 00:34:51 +03:00
var async = require('async');
var json2csv = require('json-2-csv').json2csv;
2016-05-24 22:01:46 -04:00
2016-09-16 00:34:51 +03:00
var meta = require('../../meta');
var analytics = require('../../analytics');
2016-05-24 22:01:46 -04:00
2017-06-22 19:03:49 -04:00
var errorsController = module.exports;
2016-05-24 22:01:46 -04:00
errorsController.get = function (req, res, next) {
2017-06-22 19:03:49 -04:00
async.waterfall([
function (next) {
async.parallel({
'not-found': async.apply(meta.errors.get, true),
analytics: async.apply(analytics.getErrorAnalytics),
}, next);
},
function (data) {
res.render('admin/advanced/errors', data);
},
], next);
2016-05-24 22:01:46 -04:00
};
errorsController.export = function (req, res, next) {
2016-05-24 23:04:57 -04:00
async.waterfall([
async.apply(meta.errors.get, false),
2017-02-17 19:31:21 -07:00
async.apply(json2csv),
2017-06-22 19:03:49 -04:00
function (csv) {
res.set('Content-Type', 'text/csv').set('Content-Disposition', 'attachment; filename="404.csv"').send(csv);
},
], next);
2016-05-24 23:04:57 -04:00
};