fallen-ecstasy/NovaCode-Server

Feature : Create APIs for Coding Problems

Closed this issue · 6 comments

Implement API Routes for Retrieving Problems

Description:

Create API routes to fetch coding problems based on different criteria. Users should be able to get all problems, problems by category, and retrieve a specific problem by ID or title.

Tasks:

  1. Get All Problems API:

    • Endpoint: /api/problems
    • HTTP Method: GET
    • Request Template:
      // No request required for fetching all problems
    • Response Template:
      [
        {
          "pid": Number,
          "title": String,
          "level": String,
          "companies": [String],
          // Additional problem details...
        },
        // Additional problems...
      ]
    • Guidelines for Contributor:
      • Implement an API endpoint to fetch all coding problems.
      • Ensure that the response includes essential details like problem ID, title, level, and associated companies.
  2. Get Problems by Category API:

    • Endpoint: /api/problems/category/:category
    • HTTP Method: GET
    • Request Template:
      // No request required for fetching problems by category
    • Response Template:
      [
        {
          "pid": Number,
          "title": String,
          "level": String,
          "companies": [String],
          // Additional problem details...
        },
        // Additional problems in the specified category...
      ]
    • Guidelines for Contributor:
      • Implement an API endpoint to fetch coding problems based on a specified category.
      • Ensure that the response structure is similar to the "Get All Problems" API.
  3. Get Single Problem API:

    • Endpoint: /api/problems/:idOrTitle
    • HTTP Method: GET
    • Request Template:
      // No request required for fetching a single problem
    • Response Template:
      {
        "pid": Number,
        "title": String,
        "level": String,
        "companies": [String],
        // Additional problem details...
      }
    • Guidelines for Contributor:
      • Implement an API endpoint to fetch a single coding problem based on either the problem ID or title.
      • Ensure that the response includes essential details like problem ID, title, level, and associated companies.

Additional Notes:

  • Include proper error handling for cases where problems are not found or when there are issues with the database.
  • Test the new API routes thoroughly, considering different use cases.
  • Update the project's API documentation to include details about the newly added routes.

Reference Links:


Pls assign it to me

@VaibhavGagneja Assigned this to you !
Do write test if you can using Mocha+Chai

@VaibhavGagneja Assigned this to you !
Do write test if you can using Mocha+Chai

Okay thanks

@fallen-ecstasy pls review this, the folder structure, conventions etc https://github.com/VaibhavGagneja/NovaCode-Server/tree/feature/issue-8/create-apis-for-coding-problem
tasks :- apis created , mongoose auto increment changed to mongoose-plugin-autoinc (was causing errors).

Create a PR, then it will much easier to review.

Create a PR, then it will much easier to review.

Created PR pls check