add debugging
This commit is contained in:
@@ -10,7 +10,10 @@ import { weekStart, addDaysStr, todayInTz, resolveTz } from '@shared/timezone';
|
||||
// frequency, this-week start/completeBy (so it expires and purges naturally).
|
||||
export async function POST(event: RequestEvent) {
|
||||
const u = event.locals.user;
|
||||
if (!u) throw error(401, 'Unauthorized');
|
||||
if (!u) {
|
||||
console.error('[diag] todos 401 (no session)');
|
||||
throw error(401, 'Unauthorized');
|
||||
}
|
||||
const body = await event.request.json().catch(() => ({}));
|
||||
const name = typeof body.name === 'string' ? body.name.trim().slice(0, 80) : '';
|
||||
if (!name) throw error(400, 'Give your todo a name');
|
||||
@@ -43,8 +46,12 @@ export async function POST(event: RequestEvent) {
|
||||
startDate: today,
|
||||
completeBy
|
||||
});
|
||||
console.log(`[diag] todo ok member=${u.id} fam=${u.famId} todo=${record.id} name=${name}`);
|
||||
return json({ record });
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`[diag] todo 400 member=${u.id} role=${u.role} fam=${u.famId} name=${name} err=${e instanceof Error ? e.message : e}`
|
||||
);
|
||||
throw error(400, e instanceof Error ? e.message : 'Could not add todo');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user