Skip to content

nitro56565/backend_osumare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

backend_osumare

backend Project

API Documentation

Overview

This API allows users to manage a collection of tasks with basic CRUD operations. The tasks are stored in memory, and the API supports creating, reading, updating, and deleting tasks.

Endpoints

Retrieve all tasks

URL: /tasks

Method: GET

Description: Retrieve a list of all tasks.

Response:

Status Code: 200 OK

Content-Type: text/html

Body: Renders a list of tasks using the index.ejs view.

Retrieve a specific task by ID

URL: /tasks/:id

Method: GET

Description: Retrieve a specific task by its ID.

Parameters:

  • id (required): ID of the task to retrieve.

Response:

Status Code: 200 OK

Content-Type: text/html

Body: Renders the specific task using the display.ejs view.

Create a new task

URL: /tasks

Method: POST

Description: Create a new task.

Request Body:

{
    "title": "New Task",
    "description": "Description for new task"
}

Response:

Status Code: 302 Found (Redirects to /tasks)

Body: Redirects to the list of tasks.

Error Response:

Status Code: 400 Bad Request

Content-Type: text/html

Body: Renders missing-data.ejs view if title or description is missing.

Update an existing task by ID

URL: /tasks/:id

Method: PUT

Description: Update an existing task by its ID.

Parameters:

  • id (required): ID of the task to update.

Request Body:

{
    "title": "Updated Task",
    "description": "Updated description for task"
}

Response:

Status Code: 302 Found (Redirects to /tasks)

Body: Redirects to the list of tasks.

Error Response:

Status Code: 400 Bad Request

Content-Type: text/html

Body: Renders missing-data.ejs view if title or description is missing.

Delete a task by ID

URL: /tasks/:id

Method: DELETE

Description: Delete a task by its ID.

Parameters:

  • id (required): ID of the task to delete.

Response:

Status Code: 302 Found (Redirects to /tasks)

Body: Redirects to the list of tasks.

Running the API Locally

  1. Install dependencies
    npm install express ejs method-override uuid
  2. Start the server
    node app.js
  3. Access the API

    Open a web browser and go to http://localhost:8080/tasks to view the tasks.

Example curl Commands

Retrieve all tasks

curl -X GET http://localhost:8080/tasks

Retrieve a specific task by ID

curl -X GET http://localhost:8080/tasks/<task-id>

Create a new task

curl -X POST http://localhost:8080/tasks -H "Content-Type: application/json" -d '{"title":"New Task","description":"Description for new task"}'

Update an existing task by ID

curl -X PUT http://localhost:8080/tasks/<task-id> -H "Content-Type: application/json" -d '{"title":"Updated Task","description":"Updated description for task"}'

Delete a task by ID

curl -X DELETE http://localhost:8080/tasks/<task-id>

About

backend Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published