From bedff8c0f5d0af9f6c8068565a3f46f75275d23b Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Tue, 20 Feb 2024 21:29:10 -0500 Subject: [PATCH] Start setting up FORM parser --- server/src/index.ts | 3 +-- server/src/middleware/form-to-json.ts | 8 +++----- server/src/routes/user.ts | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/server/src/index.ts b/server/src/index.ts index 22719bf..e22b7e2 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -26,7 +26,7 @@ app.onError((err: Error, c: Context) => { } return c.json({ message: "An error occurred." }); -}) +}); // // set routes @@ -57,5 +57,4 @@ app.get('/:channel', (c: Context) => { // feed actions -console.log("Running app on :3000"); export default app; diff --git a/server/src/middleware/form-to-json.ts b/server/src/middleware/form-to-json.ts index 46cc37c..5750da0 100644 --- a/server/src/middleware/form-to-json.ts +++ b/server/src/middleware/form-to-json.ts @@ -2,12 +2,10 @@ import { Context } from 'hono'; export default async function parsedForm(c: Context, next) { if (c.req.method == 'POST') { - if (c.req.header('Content-Type') == 'application/json') { - next(); - } else { - + if (c.req.header('Content-Type') === 'application/x-www-form-urlencoded') { + } } - + next(); } diff --git a/server/src/routes/user.ts b/server/src/routes/user.ts index 78bad4d..4b18856 100644 --- a/server/src/routes/user.ts +++ b/server/src/routes/user.ts @@ -14,7 +14,7 @@ app.post('/register', async (c: Context) => { try { const results = await conn.query(query, [ - user.username, + user.email, user.name, user.password ]);