mirror of
https://github.com/zadam/trilium.git
synced 2024-11-16 04:35:40 +08:00
36 lines
No EOL
842 B
JavaScript
36 lines
No EOL
842 B
JavaScript
const ipcMain = require('electron').ipcMain;
|
|
|
|
function init(app) {
|
|
ipcMain.on('server-request', (event, arg) => {
|
|
const req = {};
|
|
req.url = arg.url;
|
|
req.method = arg.method;
|
|
req.body = arg.data;
|
|
req.headers = arg.headers;
|
|
req.session = {
|
|
loggedIn: true
|
|
};
|
|
|
|
const res = {
|
|
statusCode: 200
|
|
};
|
|
|
|
res.setHeader = function() {};
|
|
|
|
res.status = function(statusCode) {
|
|
res.statusCode = statusCode;
|
|
};
|
|
|
|
res.send = function(obj) {
|
|
event.sender.send('server-response', {
|
|
requestId: arg.requestId,
|
|
statusCode: res.statusCode,
|
|
body: obj
|
|
});
|
|
};
|
|
|
|
return app._router.handle(req, res, () => {});
|
|
});
|
|
}
|
|
|
|
module.exports = init; |