mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08: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; | 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) => { |     ipcMain.on('server-request', (event, arg) => { | ||||||
|         const req = { |         const req = { | ||||||
|             url: arg.url, |             url: arg.url, | ||||||
| @ -12,9 +23,9 @@ function init(app) { | |||||||
|             } |             } | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         const respHeaders = {}; |         const respHeaders: Record<string, string> = {}; | ||||||
| 
 | 
 | ||||||
|         const res = { |         const res: Response = { | ||||||
|             statusCode: 200, |             statusCode: 200, | ||||||
|             getHeader: name => respHeaders[name], |             getHeader: name => respHeaders[name], | ||||||
|             setHeader: (name, value) => { |             setHeader: (name, value) => { | ||||||
| @ -45,4 +56,4 @@ function init(app) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = init; | export = init; | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran