-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconstant.ts
86 lines (83 loc) · 1.88 KB
/
constant.ts
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
/*
* @Author: legends-killer
* @Date: 2021-11-27 17:41:57
* @LastEditors: legends-killer
* @LastEditTime: 2021-12-02 15:49:16
* @Description:
*/
import { ISystemInfo, ISystemSettingErrorReport, ErrorEmailType } from './typings/types'
// do not modify this
export const appInitInfo: ISystemInfo = {
warn: 0,
error: 0,
cache: {
api: {
total: 0,
missed: 0,
syncAt: new Date('1999'),
},
biz: {
total: 0,
missed: 0,
syncAt: new Date('1999'),
},
user: {
total: 0,
missed: 0,
syncAt: new Date('1999'),
},
},
proxyInfo: {
proxy: 0,
proxyWarn: 0,
proxyError: 0,
test: 0,
testError: 0,
testWarn: 0,
},
}
// error report email template
export const systemErrorReportEmailTemplate = (
error: number,
warn: number,
config: ISystemSettingErrorReport,
type: ErrorEmailType
) => `
<html>
<body style="font-family: sans-serif, system-ui">
<h2>This is an error report from Niko-Gateway.</h2>
<p>
<strong>
Niko has found that your ${type} error or warn increased to a threshold
</strong>
</p>
<p>
<strong>In the last ${config.timeThreshold} mins by your setting</strong>
</p>
<p style="color: #ffae00">${type} Warn<strong>${warn}</strong></p>
<p style="color: #ff0000">${type} Error<strong> ${error}</strong></p>
<p>Nya~</p>
</body>
</html>
`
export const TransNumberArray = {
from: (value: string) => {
if (value === undefined) return ''
return value.split(',').map((r) => {
return Number(r)
})
},
to: (value: Array<string | number> | undefined) => {
if (value === undefined) return ''
return value.toString()
},
}
export const TransJson = {
from(val: string) {
return JSON.parse(val)
},
to(val: { [index: string]: string } | undefined) {
if (!val) return '{}'
return JSON.stringify(val)
},
}