-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
receive hackatons directly from firebase
- Loading branch information
1 parent
f885765
commit 8dbca30
Showing
6 changed files
with
35 additions
and
29 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 |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import { NextApiRequest, NextApiResponse } from 'next'; | ||
import db from '../../utils/server/database'; | ||
import { Hackathon } from '../../types/hackathon'; | ||
import getHackathons from '../../utils/firebase/getHackathons'; | ||
|
||
const getHackathons = async (_: NextApiRequest, res: NextApiResponse) => { | ||
const hackathonsHandler = async (_: NextApiRequest, res: NextApiResponse) => { | ||
try { | ||
const hackathonsRef = db.ref('hackathons'); | ||
const snapshot = await hackathonsRef.once('value'); | ||
const hackathons: Hackathon[] = snapshot.val(); | ||
const hackathons = await getHackathons(); | ||
|
||
res.status(200).json({ hackathons }); | ||
} catch (e) { | ||
res.status(500).json({ error: e.message }); | ||
} | ||
}; | ||
|
||
export default getHackathons; | ||
export default hackathonsHandler; |
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,19 @@ | ||
import getFirebaseInstance from './getFirebaseInstance'; | ||
import { Hackathon } from '../../types/hackathon'; | ||
|
||
const getHackathons = async () => { | ||
const firebaseInstance = getFirebaseInstance(); | ||
const hackathonsRef = firebaseInstance.database().ref('hackathons'); | ||
const snapshot = await hackathonsRef.once('value'); | ||
const hackathons: Hackathon[] = snapshot.val(); | ||
|
||
try { | ||
// required for netlify https://5f723a99796e900007e9382a--growth-points.netlify.app/ | ||
await firebaseInstance.delete(); | ||
} finally { | ||
// eslint-disable-next-line no-unsafe-finally | ||
return hackathons; | ||
} | ||
}; | ||
|
||
export default getHackathons; |
This file was deleted.
Oops, something went wrong.