Valentyne Stigloher 10180aa6a3 (refactor) use #shared alias instead of ~~/shared
the #shared alias used by Nuxt cannot be easily disabled and to prevent breackage with jiti, we make use of it
2025-08-17 18:56:02 +02:00

13 lines
443 B
TypeScript

import SQL from 'sql-template-strings';
import type { User } from '#shared/user.ts';
import type { Database } from '~~/server/db.ts';
export const isAllowedToPost = async (db: Database, user: User | null): Promise<boolean> => {
if (!user) {
return false;
}
const dbUser = await db.get<Pick<User, 'bannedReason'>>(SQL`SELECT bannedReason FROM users WHERE id = ${user.id}`);
return !!dbUser && !dbUser.bannedReason;
};