mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
feat(writeapi): topic posting and replying
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
const nconf = require('nconf');
|
||||
const validator = require('validator');
|
||||
const querystring = require('querystring');
|
||||
const url = require('url');
|
||||
const _ = require('lodash');
|
||||
|
||||
const user = require('../user');
|
||||
@@ -413,4 +414,28 @@ helpers.generateError = (statusCode, message) => {
|
||||
return payload;
|
||||
};
|
||||
|
||||
helpers.buildReqObject = (req) => {
|
||||
var headers = req.headers;
|
||||
var encrypted = !!req.connection.encrypted;
|
||||
var host = headers.host;
|
||||
var referer = headers.referer || '';
|
||||
if (!host) {
|
||||
host = url.parse(referer).host || '';
|
||||
}
|
||||
|
||||
return {
|
||||
uid: req.uid,
|
||||
params: req.params,
|
||||
method: req.method,
|
||||
body: req.body,
|
||||
ip: req.ip,
|
||||
host: host,
|
||||
protocol: encrypted ? 'https' : 'http',
|
||||
secure: encrypted,
|
||||
url: referer,
|
||||
path: referer.substr(referer.indexOf(host) + host.length),
|
||||
headers: headers,
|
||||
};
|
||||
};
|
||||
|
||||
require('../promisify')(helpers);
|
||||
|
||||
Reference in New Issue
Block a user