-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
38 lines (34 loc) · 1.02 KB
/
utils.js
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
const Config = require('./config.js')
const codeMaps = Object.freeze({
OK: { code: 200, error: 0, msg: '成功' },
ERR_AUTH: { code: 401, error: 1, msg: '权限校验失败' },
ERR_AUTH2: { code: 403, error: 1, msg: '权限校验失败' },
ERR_INTERNAL: { code: 500, error: 1, msg: '服务器错误' },
})
const build = (respCode, data = null) => {
let { code, msg = 'ok', error = 0 } = respCode
if (data?.msg) {
msg = data.msg
data = data?.data || null
}
return { code, msg, error, data: data }
}
// 发送验证码邮件模版
const emailTemplate = code => {
return `<div>Welcome!</div>
<div>Thank you for joining my tabs extentions services!</div>
<div>To verify your account, please enter thecode below in the window where youstarted creating your account.
</div>
<br>
<h2>${code}</h2>
<br>
<div>Thanks again for signing up!
</div>
<div>P.S. lf you have any questions, please <a href="mailto:${Config.mailAddress}">click here</a>.
</div>`
}
module.exports = {
codeMaps,
build,
emailTemplate: emailTemplate,
}