-
Notifications
You must be signed in to change notification settings - Fork 2
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
9 changed files
with
70 additions
and
60 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,31 @@ | ||
import { VercelRequest, VercelResponse } from "@vercel/node"; | ||
import { authenticatedRoute } from "../../libs/middleware"; | ||
import { User } from "../../common/UserProvider"; | ||
import { getFirestoreDB } from "../../libs/firestoreDB"; | ||
|
||
/** | ||
* Returns a list of all database entries containing | ||
* the current user's userAuthId. | ||
*/ | ||
const getEventsHandler = async ( | ||
req: VercelRequest, | ||
res: VercelResponse, | ||
user: User | ||
): Promise<void> => { | ||
try { | ||
const db = getFirestoreDB(); | ||
|
||
const events: Object[] = []; | ||
const snapshot = await db.collection('ScheduledEvents').where('userAuthId', '==', user.authId).get(); | ||
snapshot.forEach(doc => { | ||
events.push(doc.data()); | ||
}); | ||
|
||
res.status(200).json({ events: events }); | ||
} catch (error) { | ||
console.error('Error in getEventsHandler:', error); | ||
res.status(500).json({ error: 'Internal Server Error' }); | ||
} | ||
}; | ||
|
||
export default authenticatedRoute(getEventsHandler); |
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
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,17 @@ | ||
import { VercelRequest, VercelResponse } from "@vercel/node"; | ||
import { getAllActivities } from "../../../libs/activitiesAPI"; | ||
|
||
/** | ||
* Return JSON of all activities in /db/activities | ||
*/ | ||
const allPages = async (req: VercelRequest, res: VercelResponse): Promise<void> => { | ||
try { | ||
const allPages = await getAllActivities(); | ||
res.status(200).json(allPages); | ||
} catch (error) { | ||
console.error("Error in allPages:", error); | ||
res.status(502).json({ error: "Internal Server Error" }); | ||
} | ||
}; | ||
|
||
export default allPages; |
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