sef-global / scholarx-backend

This is the backend of the ScholarX
MIT License
10 stars 37 forks source link

Refactor controller functions to return specific types instead of 'void' #66

Closed Madhawa97 closed 11 months ago

Madhawa97 commented 11 months ago

Description: In our codebase, we have multiple controller functions that are currently typed as Promise<void>. While working on a recent pull request (#65), a suggestion was made to modify these functions to return data with specific types instead of void. This suggestion was made to improve the consistency and type safety of our codebase.

Tasks:

An example of the suggested code change:

// Before
async function someControllerFunction(req: Request, res: Response): Promise<void> {
  // ... existing code
  res.status(statusCode).json({ /* some data */ });
}

// After
interface ResponseData {
  /* Define the specific structure of the response data */
}

async function someControllerFunction(req: Request, res: Response): Promise<ResponseData> {
  // ... existing code
  const responseData: ResponseData = { /* some data */ };
  return res.status(statusCode).json(responseData);
}

Acceptance Criteria:

Additional Information: None

Related Dependencies or References:

65