clear up internal libs (@Jack5079)

This commit is contained in:
May 2023-10-03 20:16:05 -07:00
parent 1ed1acca1c
commit 9a589d3638
2 changed files with 23 additions and 29 deletions

View file

@ -35,8 +35,7 @@ export interface Account {
* @returns A Promise which returns the new account's ID * @returns A Promise which returns the new account's ID
*/ */
export function create(username:string,pwd:string,admin:boolean=false):Promise<string> { export async function create(username:string,pwd:string,admin:boolean=false):Promise<string> {
return new Promise((resolve,reject) => {
let accId = crypto.randomBytes(12).toString("hex") let accId = crypto.randomBytes(12).toString("hex")
Accounts.push( Accounts.push(
@ -50,8 +49,8 @@ export function create(username:string,pwd:string,admin:boolean=false):Promise<s
} }
) )
save().then(() => resolve(accId)) await save()
}) return accId
} }
/** /**

View file

@ -27,8 +27,7 @@ transport =
* @returns Promise which resolves to the output from nodemailer.transport.sendMail * @returns Promise which resolves to the output from nodemailer.transport.sendMail
*/ */
export function sendMail(to: string, subject: string, content: string) { export function sendMail(to: string, subject: string, content: string) {
return new Promise((resolve,reject) => { return transport.sendMail({
transport.sendMail({
to, to,
subject, subject,
"from": mailConfig.send.from, "from": mailConfig.send.from,
@ -37,9 +36,5 @@ export function sendMail(to: string, subject: string, content: string) {
.replace(/\<span username\>/g, `<span code><span style="color:#DDAA66;padding-right:3px;">@</span>`) .replace(/\<span username\>/g, `<span code><span style="color:#DDAA66;padding-right:3px;">@</span>`)
.replace(/\<span code\>/g,`<span style="font-family:monospace;padding:3px 5px 3px 5px;border-radius:8px;background-color:#1C1C1C;color:#DDDDDD;">`) .replace(/\<span code\>/g,`<span style="font-family:monospace;padding:3px 5px 3px 5px;border-radius:8px;background-color:#1C1C1C;color:#DDDDDD;">`)
}<br><br><span style="opacity:0.5">If you do not believe that you are the intended recipient of this email, please disregard this message.</span>` }<br><br><span style="opacity:0.5">If you do not believe that you are the intended recipient of this email, please disregard this message.</span>`
}, (err, info) => {
if (err) reject(err)
else resolve(info)
})
}) })
} }