-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
87 lines (75 loc) · 3.22 KB
/
main.ts
File metadata and controls
87 lines (75 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { app } from 'electron'
import contextMenu from 'electron-context-menu'
import log from 'electron-log'
import express from 'express'
import sharp from 'sharp'
// Every mutation to any original/export/thumbnail is tracked in the log
// 1000 MB ensures even if you have thousands of creations or deletions, they will be tracked
log.transports.file.maxSize = 1000 * 1024 * 1024 // 1000 MB
console.log = log.info
console.error = log.error
console.warn = log.warn
console.debug = log.debug
contextMenu({ showSaveImageAs: true })
const pathSeparator = process.platform === 'win32' ? ';' : ':'
process.env.PATH =
['/opt/homebrew/bin', '/opt/homebrew/sbin'].join(pathSeparator) +
pathSeparator +
process.env.PATH
import { createWindow } from './server/createWindow.js'
import { registerDeleteFilesAction } from './server/registerDeleteFilesAction.js'
import { registerDeleteFileTagAction } from './server/registerDeleteFileTagAction.js'
import { registerDeleteTagAction } from './server/registerDeleteTagAction.js'
import { registerGetDataAction } from './server/registerGetDataAction.js'
import { registerGetFile } from './server/registerGetFile.js'
import { registerGetSelectedTagsAction } from './server/registerGetSelectedTagsAction.js'
import { registerMakeTagAction } from './server/registerMakeTagAction.js'
import { registerMyImageProtocol } from './server/registerMyImageProtocol.js'
import { registerMyVideoProtocol } from './server/registerMyVideoProtocol.js'
import { registerOpenFileAction } from './server/registerOpenFileAction.js'
import { registerOpenFileInFinderAction } from './server/registerOpenFileInFinderAction.js'
import { registerPublishAction } from './server/registerPublishAction.js'
import { registerRotatePhotoAction } from './server/registerRotatePhotoAction.js'
import { registerSyncAction } from './server/registerSyncAction.js'
import { registerTagItemsAction } from './server/registerTagItemsAction.js'
import { registerUpdateTagAction } from './server/registerUpdateTagAction.js'
type RouteResponse = any
app.whenReady().then(() => {
const PORT = 45678
const expressApp = express()
expressApp.get('/healthz', (_req, res): RouteResponse => {
console.log(`Path: ${process.env.PATH}`)
console.log(`${JSON.stringify(sharp.format)}`)
return res.send('The server is healthy!')
})
expressApp.listen(PORT, () => {
console.log(`Express server running at http://localhost:${PORT}`)
})
const browserWindow = createWindow()
// Register protocols
registerMyImageProtocol()
registerMyVideoProtocol()
// Register actions
// This first action also loads the database and applies the migrations
// It must be run on the before anything else is run
registerGetDataAction(browserWindow)
// The rest of the actions
registerDeleteFilesAction(browserWindow)
registerDeleteFileTagAction()
registerDeleteTagAction()
registerGetFile()
registerGetSelectedTagsAction()
registerMakeTagAction()
registerOpenFileAction()
registerOpenFileInFinderAction()
registerRotatePhotoAction()
registerTagItemsAction()
registerUpdateTagAction()
registerSyncAction(browserWindow)
registerPublishAction(browserWindow)
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})