Backend half

This commit is contained in:
2025-07-11 19:56:28 +02:00
parent fa868e7c1d
commit 8600fa7c1d
19426 changed files with 3750448 additions and 8108 deletions
@@ -0,0 +1,34 @@
import { Request, Response } from 'express';
import { UserQueryDispatcher } from '../../functions/Users/Queries/UserQueryDispatcher';
import { UserCommandDispatcher } from '../../functions/Users/Commands/UserCommandDispatcher';
import { UserExistsQuery } from '../../functions/Users/Queries/UserQuery';
export async function checkUserExists(
req: Request,
res: Response,
queryDispatcher: UserQueryDispatcher,
commandDispatcher: UserCommandDispatcher
): Promise<void> {
try {
if(!req.user || !req.user.id) {
res.status(401).json({
success: false,
message: 'Unauthorized access - user not authenticated'
});
return;
}
const id = req.user.id.toString();
const query = new UserExistsQuery(parseInt(id));
const exists = await queryDispatcher.dispatch(query);
res.status(200).json({
success: true,
exists
});
} catch (error: any) {
res.status(500).json({
success: false,
message: error.message || 'Failed to check user existence'
});
}
}