Skip to content

Latest commit

 

History

History
439 lines (390 loc) · 6.29 KB

File metadata and controls

439 lines (390 loc) · 6.29 KB

API Documentation

Base URL

http://localhost:5000/api

Authentication

Register

POST /auth/register

Request Body:

{
  "name": "string",
  "email": "string",
  "password": "string"
}

Response:

{
  "token": "string",
  "user": {
    "id": "string",
    "name": "string",
    "email": "string",
    "role": "user|admin",
    "anonymousMode": "boolean"
  }
}

Login

POST /auth/login

Request Body:

{
  "email": "string",
  "password": "string"
}

Response:

{
  "token": "string",
  "user": {
    "id": "string",
    "name": "string",
    "email": "string",
    "role": "user|admin",
    "anonymousMode": "boolean"
  }
}

Google Auth

POST /auth/google

Request Body:

{
  "name": "string",
  "email": "string",
  "googleId": "string"
}

Response:

{
  "token": "string",
  "user": {
    "id": "string",
    "name": "string",
    "email": "string",
    "role": "user|admin",
    "anonymousMode": "boolean"
  }
}

Reports

Create Report

POST /reports

Requires authentication

Request Body:

{
  "title": "string",
  "description": "string",
  "category": "used car|electronics|services",
  "location": "string",
  "images": ["string"],
  "links": ["string"]
}

Response:

{
  "id": "string",
  "title": "string",
  "description": "string",
  "category": "string",
  "location": "string",
  "images": ["string"],
  "links": ["string"],
  "authorId": "string",
  "status": "pending|verified|rejected",
  "upvotes": "number",
  "downvotes": "number",
  "comments": ["string"],
  "createdAt": "date",
  "updatedAt": "date"
}

Get Reports

GET /reports

Query Parameters:

  • category (optional): Filter by category
  • location (optional): Filter by location
  • search (optional): Search by keyword
  • page (optional): Page number (default: 1)
  • limit (optional): Items per page (default: 6)

Response:

{
  "reports": [
    {
      "id": "string",
      "title": "string",
      "description": "string",
      "category": "string",
      "location": "string",
      "images": ["string"],
      "links": ["string"],
      "authorId": "string",
      "status": "pending|verified|rejected",
      "upvotes": "number",
      "downvotes": "number",
      "comments": ["string"],
      "createdAt": "date",
      "updatedAt": "date"
    }
  ],
  "pagination": {
    "currentPage": "number",
    "totalPages": "number",
    "totalReports": "number"
  }
}

Get Report by ID

GET /reports/:id

Response:

{
  "id": "string",
  "title": "string",
  "description": "string",
  "category": "string",
  "location": "string",
  "images": ["string"],
  "links": ["string"],
  "authorId": "string",
  "status": "pending|verified|rejected",
  "upvotes": "number",
  "downvotes": "number",
  "comments": [
    {
      "id": "string",
      "reportId": "string",
      "userId": "string",
      "content": "string",
      "createdAt": "date"
    }
  ],
  "createdAt": "date",
  "updatedAt": "date"
}

Verify Report

PUT /reports/:id/verify

Requires authentication and admin role

Response:

{
  "id": "string",
  "title": "string",
  "description": "string",
  "category": "string",
  "location": "string",
  "images": ["string"],
  "links": ["string"],
  "authorId": "string",
  "status": "verified",
  "upvotes": "number",
  "downvotes": "number",
  "comments": ["string"],
  "verifiedBy": "string",
  "createdAt": "date",
  "updatedAt": "date"
}

Upvote Report

PUT /reports/:id/upvote

Response:

{
  "upvotes": "number"
}

Downvote Report

PUT /reports/:id/downvote

Response:

{
  "downvotes": "number"
}

Add Comment

POST /reports/:id/comment

Requires authentication

Request Body:

{
  "content": "string"
}

Response:

{
  "id": "string",
  "reportId": "string",
  "userId": "string",
  "content": "string",
  "createdAt": "date"
}

Delete Report

DELETE /reports/:id

Requires authentication (owner or admin)

Response:

{
  "message": "Bildirim başarıyla silindi"
}

Search

Search Reports

GET /search

Query Parameters:

  • q (optional): Search query
  • category (optional): Filter by category
  • location (optional): Filter by location
  • date (optional): Filter by date

Response:

[
  {
    "id": "string",
    "title": "string",
    "description": "string",
    "category": "string",
    "location": "string",
    "images": ["string"],
    "links": ["string"],
    "authorId": "string",
    "status": "pending|verified|rejected",
    "upvotes": "number",
    "downvotes": "number",
    "comments": ["string"],
    "createdAt": "date",
    "updatedAt": "date"
  }
]

Admin

Get Pending Reports

GET /admin/reports/pending

Requires authentication and admin role

Response:

[
  {
    "id": "string",
    "title": "string",
    "description": "string",
    "category": "string",
    "location": "string",
    "images": ["string"],
    "links": ["string"],
    "authorId": "string",
    "status": "pending",
    "upvotes": "number",
    "downvotes": "number",
    "comments": ["string"],
    "createdAt": "date",
    "updatedAt": "date"
  }
]

Get Users

GET /admin/users

Requires authentication and admin role

Response:

[
  {
    "id": "string",
    "name": "string",
    "email": "string",
    "role": "user|admin",
    "anonymousMode": "boolean",
    "createdAt": "date",
    "reportCount": "number"
  }
]

Block User

PUT /admin/users/:userId/block

Requires authentication and admin role

Response:

{
  "message": "Kullanıcı başarıyla engellendi",
  "user": {
    "id": "string",
    "name": "string",
    "email": "string",
    "role": "blocked",
    "anonymousMode": "boolean",
    "createdAt": "date"
  }
}

Contact

Send Contact Message

POST /contact

Request Body:

{
  "name": "string",
  "email": "string",
  "subject": "string",
  "message": "string"
}

Response:

{
  "message": "Mesajınız başarıyla gönderildi"
}

Health Check

API Status

GET /health

Response:

{
  "status": "OK",
  "message": "IfşaEdici API is running"
}