mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
7f1d3ebc07
- move all test files from core/test to test/ - updated all imports and other references - all code inside of core/ is then application code - tests are correctly at the root level - consistent with other repos/projects Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
const _ = require('lodash');
|
|
const http = require('http');
|
|
|
|
module.exports = {
|
|
invoke: function (app, reqParams) {
|
|
let req = new http.IncomingMessage();
|
|
let res = new http.ServerResponse({
|
|
method: reqParams.method
|
|
});
|
|
|
|
res.end = function () {
|
|
this.emit('finish');
|
|
};
|
|
|
|
req.connection = {
|
|
encrypted: reqParams.secure
|
|
};
|
|
|
|
req.method = 'GET';
|
|
req.url = reqParams.url;
|
|
req.headers = {
|
|
host: reqParams.host
|
|
};
|
|
|
|
res.connection = {
|
|
_httpMessage: res,
|
|
writable: true,
|
|
destroyed: false,
|
|
cork: function () {},
|
|
uncork: function () {},
|
|
write: function () {}
|
|
};
|
|
|
|
return new Promise(function (resolve) {
|
|
res.end = function (body) {
|
|
resolve({
|
|
err: res.req.err,
|
|
body: body,
|
|
statusCode: res.statusCode,
|
|
headers: res._headers,
|
|
template: res._template,
|
|
req: req,
|
|
res: res
|
|
});
|
|
};
|
|
|
|
res.send = function (body) {
|
|
resolve({
|
|
err: res.req.err,
|
|
body: body,
|
|
statusCode: res.statusCode,
|
|
headers: res._headers,
|
|
template: res._template,
|
|
req: req,
|
|
res: res
|
|
});
|
|
};
|
|
|
|
app(req, res);
|
|
});
|
|
}
|
|
};
|