From d860ef7f98edfb83a06bc3968b3767b3d8d9b093 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 30 Apr 2023 12:39:47 -0500 Subject: [PATCH] Apps: get the redirect_uri into the app --- src/api/apps.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/api/apps.ts b/src/api/apps.ts index cdaa124..c3ebee3 100644 --- a/src/api/apps.ts +++ b/src/api/apps.ts @@ -14,8 +14,18 @@ const FAKE_APP = { vapid_key: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=', }; -function createAppController(c: Context) { - return c.json(FAKE_APP); +async function createAppController(c: Context) { + // TODO: Handle both formData and json. 422 on parsing error. + try { + const { redirect_uris } = await c.req.json(); + + return c.json({ + ...FAKE_APP, + redirect_uri: redirect_uris || FAKE_APP.redirect_uri, + }); + } catch (_e) { + return c.json(FAKE_APP); + } } function appCredentialsController(c: Context) {