Consistency fixes
This commit is contained in:
@@ -2,11 +2,11 @@ import { MySql2Database } from 'drizzle-orm/mysql2'
|
|||||||
import { users } from './tables'
|
import { users } from './tables'
|
||||||
import { eq } from 'drizzle-orm'
|
import { eq } from 'drizzle-orm'
|
||||||
|
|
||||||
export async function checkAuthorization (
|
export const checkAuthorization = async (
|
||||||
authorizationToken: string,
|
authorizationToken: string,
|
||||||
db0: MySql2Database,
|
db0: MySql2Database,
|
||||||
updateIp: string | null
|
updateIp: string | null
|
||||||
) {
|
) => {
|
||||||
if (!authorizationToken) return { valid: false, id: 0 }
|
if (!authorizationToken) return { valid: false, id: 0 }
|
||||||
|
|
||||||
const userData = await db0
|
const userData = await db0
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ import { createHash } from 'crypto'
|
|||||||
import { and, eq, sql } from 'drizzle-orm'
|
import { and, eq, sql } from 'drizzle-orm'
|
||||||
import { verifyCodes } from './tables'
|
import { verifyCodes } from './tables'
|
||||||
|
|
||||||
export function jsonResponse (data: any, status = 200) {
|
export const jsonResponse = (data: any, status = 200) => {
|
||||||
return new Response(JSON.stringify(data, null, 2), {
|
return new Response(JSON.stringify(data, null, 2), {
|
||||||
status,
|
status,
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDatabaseConnection (type: number) {
|
export const getDatabaseConnection = (type: number) => {
|
||||||
if (type !== 0 && type !== 1) return null
|
if (type !== 0 && type !== 1) return null
|
||||||
|
|
||||||
const env =
|
const env =
|
||||||
@@ -199,6 +199,6 @@ export const sendEmail = async (to: string, title: string, body: string) => {
|
|||||||
return await transporter.sendMail(mailOptions)
|
return await transporter.sendMail(mailOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hash (input: string, type: string): string {
|
export const hash = (input: string, type: string): string => {
|
||||||
return createHash(type).update(input).digest('hex')
|
return createHash(type).update(input).digest('hex')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user