-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
273 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { adminDb } from '$lib/server/firebase'; | ||
import { json, type RequestHandler } from '@sveltejs/kit'; | ||
|
||
export const POST: RequestHandler = async ({ request, params, locals }) => { | ||
if (!locals.user) { | ||
return json({ error: 'Unauthorized' }, { status: 401 }); | ||
} | ||
|
||
const { id } = params; | ||
const { goal, subQuestions } = await request.json(); | ||
|
||
if (!id) { | ||
return json({ error: 'Missing parameters' }, { status: 400 }); | ||
} | ||
|
||
try { | ||
const sessionRef = adminDb.collection('sessions').doc(id); | ||
await sessionRef.update({ goal, subQuestions }); | ||
|
||
return json({ success: true }); | ||
} catch (error) { | ||
console.error('Error saving session:', error); | ||
return json({ error: 'Failed to save session' }, { status: 500 }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.