Skip to content

fix(api): correct Express route signatures and add socket payload guards - #71

Open
RajGahoi wants to merge 1 commit into
apsinghdev:mainfrom
RajGahoi:fix/api-route-signatures-and-socket-guards
Open

RajGahoi wants to merge 1 commit into
apsinghdev:mainfrom
RajGahoi:fix/api-route-signatures-and-socket-guards

Conversation

@RajGahoi

Copy link
Copy Markdown

Description

This PR addresses two critical bugs in the backend Express API and adds defensive guards for socket event payloads:

1. Fix Express Route Signatures

  • In \�pi/index.js, \GET /test\ was registered as \�pp.get('/test', (res) => { res.send(...) }). In Express, the first argument passed to route handlers is the \Request\ object (
    eq). Calling
    es.send(...)\ throws a runtime \TypeError: res.send is not a function.
  • In \GET /, the handler had no arguments and never sent a response, causing health checks and HTTP clients to hang indefinitely.
  • Updated both routes to properly accept (req, res)\ and respond with JSON status.

2. Defensive Socket Payload Guards

  • Socket handlers (\joinRoom, \draw, \clear, \open-text-editor, \close-text-editor, \ ext-updated) previously accessed \data.room_id\ directly without verification, which causes unhandled TypeError exceptions if a client emits empty or non-object payloads.
  • Added optional chaining and guard checks (\data?.room_id) before emitting to rooms.

3. Node Environment in ESLint Config

  • Added \globals.node\ to \�pi/eslint.config.js\ so Node server globals are recognized by the linter.

Verification

  • Ran
    pm run lint\ in \�pi/\ — passed cleanly with 0 errors.

@vercel

vercel Bot commented Oct 24, 2026

Copy link
Copy Markdown

@RajGahoi is attempting to deploy a commit to the AJEET PRATAP SINGH's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant