mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server-ts: Convert routes/electron
This commit is contained in:
parent
4940207b15
commit
202fda3c30
@ -1,6 +1,17 @@
|
||||
import { Application } from "express";
|
||||
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
|
||||
function init(app) {
|
||||
interface Response {
|
||||
statusCode: number;
|
||||
getHeader: (name: string) => string;
|
||||
setHeader: (name: string, value: string) => Response;
|
||||
header: (name: string, value: string) => Response;
|
||||
status: (statusCode: number) => Response;
|
||||
send: (obj: {}) => void;
|
||||
}
|
||||
|
||||
function init(app: Application) {
|
||||
ipcMain.on('server-request', (event, arg) => {
|
||||
const req = {
|
||||
url: arg.url,
|
||||
@ -12,9 +23,9 @@ function init(app) {
|
||||
}
|
||||
};
|
||||
|
||||
const respHeaders = {};
|
||||
const respHeaders: Record<string, string> = {};
|
||||
|
||||
const res = {
|
||||
const res: Response = {
|
||||
statusCode: 200,
|
||||
getHeader: name => respHeaders[name],
|
||||
setHeader: (name, value) => {
|
||||
@ -45,4 +56,4 @@ function init(app) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = init;
|
||||
export = init;
|
Loading…
x
Reference in New Issue
Block a user