Skip to content

Instantly share code, notes, and snippets.

@tianhaoz95
Last active January 15, 2020 21:26
Show Gist options
  • Save tianhaoz95/f108f4c91f44054f1c35c979fed5ff5f to your computer and use it in GitHub Desktop.
Save tianhaoz95/f108f4c91f44054f1c35c979fed5ff5f to your computer and use it in GitHub Desktop.
External version of Firebase API
export const externalAwesomeAPI = functions.https.onRequest(async (req, res) => {
if (req.method !== "POST") {
return res.sendStatus(403);
}
const context: FunctionContext = await token2context(req.body.token);
const intermediateRequest: IntermediateRequestInterface = parseIntermediateRequest(req.body);
try {
await awesomeHandler(intermediateRequest, context);
return res.sendStatus(200);
} catch (err) {
return res.sendStatus(500);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment