import Auth from '../db/model/auth'; import { AuthModel, AuthPrivate } from '../db/schema/auth'; import { sign } from './jwt'; export const getAuthenticationBundle = async (username: string, password: string) => { const auth = await Auth.findByUsername(username).catch(); const isAuthenticated = !!auth && (auth).authenticate(password); const record = isAuthenticated ? (auth).record : null; const token = sign(record || undefined); return { record, token, }; };