Skip to content

MadAvidCoder/Naughty-or-Nice

Repository files navigation

Naughty or Nice API

https://naughty_nice_tracker.david-ma-6877.workers.dev/

For Day 4, I've adapted the API to keep track of who's been naughty and nice this year. I used three tables, one to jeep track of the people, one for their 'infractions' (naughty deeds), and one where they can submit appeals for why they shouldn't be on the naughty list.

Here are the different endpoints, and their parameters. If you want to read a more fun (but AI) generated version of the instructions, scroll to the bottom!


People Endpoints (Table 1)

GET /api/people

  • Description: Get the list of people and whether theyre naughty or nice.
  • Parameters: None
  • Returns: JSON array of all people records.
  • Example Response:
    [
      {
        "id": 1,
        "name": "Candy Cane",
        "isNice": true,
        "reason": "Helped an old lady cross the street",
        "checkedAt": "2024-12-01T10:00:00Z"
      },
      ...
    ]

GET /api/people/:id

  • Description: Retrieve all information about a specific person by their ID.
  • Parameters:
    • id (number): The unique identifier of the human.
  • Returns: JSON object of the person’s record.
  • Example Response:
{
  "id": 1,
  "name": "Candy Cane",
  "isNice": true,
  "reason": "Helped an old lady cross the street",
  "checkedAt": "2024-12-01T10:00:00Z"
}

POST /api/people

  • Description: Add a new entry on the Naughty & Nice list.
  • Body:
    • name (string, required): The name of the new person.
    • isNice (boolean, optional): Initial status (default: true).
    • reason (string, optional): Reason for the initial status.
  • Returns: The newly created person’s ID
  • Example Response:
{ "id": 42 }

PATCH /api/people/:id

  • Description: Revise the naughty/nice status of a person on the list
  • Parameters:
    • id (number): The unique identifier of the human.
  • Body:
    • isNice (boolean, required): Official verdict.
    • reason (string, optional): Reason for the judgement.
  • Returns: { "ok": true } on success.

DELETE /api/people/:id

  • Description: Remove an entry from the Naughty & Nice list.
  • Parameters:
    • id (number): The unique identifier of the person to be removed.
  • Returns: { "ok": true } on success.

Infractions Endpoints (Table 2)

GET /api/people/:id/infractions

  • Description: View the naughty deeds recorded against a specific person.
  • Parameters:
    • id (number): The unique identifier of the person to be checked.
  • Returns: JSON array of infractions.
  • Example Response:
[
  {
    "id": 5,
    "personId": 17,
    "description": "Stole cookies from the cookie jar",
    "severity": 3,
    "occurredAt": "2024-11-30T15:30:00Z"
  },
  ...
]

POST /api/people/:id/infractions

  • Description: Record a new infraction against a person.
  • Parameters:
    • id (number): The unique identifier of the person.
  • Body:
    • description (string, required): Description of the naughty deed.
    • severity (number, optional): Severity level from 1 (minor) to 5 (very naughty). (default: 1)
  • Returns: The ID of the newly created infraction.
  • Example Response:
{ "id": 38 }

Appeals Endpoints (Table 3)

POST /api/appeals

  • Description: Submit an appeal for a recorded infraction.
  • Body:
    • personId (number, required): The unique identifier of the person making the appeal.
    • infractionId (number, required): The unique identifier of the infraction being appealed.
    • appealText (string, required): Why you think the infraction shouldn't be counted,
  • Returns: The ID of the newly created appeal.
  • Example Response:
{ "id": 15 }

GET /api/appeals/pending

  • Description: Retrieve all appeals awaiting judgement (whether they are accepted or not)
  • Parameters: None
  • Returns: JSON array of all pending appeals.
  • Example Response:
[
  {
    "id": 15,
    "personId": 5,
    "infractionId": 28,
    "appealText": "I swear I was just borrowing the cookies!",
    "status": 0,
    "submittedAt": "2024-12-02T12:00:00Z"
  }
]

PATCH /api/appeals/:id/review

  • Description: Decide whether the appeal should be accepted.
  • Parameters:
    • id (number): The unique identifier of the appeal.
  • Body:
    • approved (boolean, required): Whether the appeal is acceptable.
  • Returns: { "ok": true } on success.
Dropdown for a Themed Version of the manual (AI Generated btw)

North Pole Official API Manual

Official API access is available to all elves via: https://naughty_nice_tracker.david-ma-6877.workers.dev/

Santa's Naughty & Nice Tracker - Elf Edition

[!CAUTION] This manual is the property of S. GIFT INC.
(Santa's Grand Institute of Festive Transparency Incorporated)

For internal use only. Any elves found to be using endpoints above their clearance level (especially those marked SACK or SUPREME) will face punitive action, including untangling Christmas lights in sub-zero temperatures.

Please read carefully.


Section 1: People Management

(aka The Naughty & Nice List)

These endpoints are used for tracking humans’ Naughty & Nice statuses, especially for when deciding who deserves coal.

GET /api/people

  • Description: Retrieve the full list of humans and their current status (naughty or nice).
  • Parameters: None
  • Returns: JSON array of all people records.
  • Example Response:
    [
      {
        "id": 1,
        "name": "Candy Cane",
        "isNice": true,
        "reason": "Helped an old lady cross the street",
        "checkedAt": "2024-12-01T10:00:00Z"
      },
      ...
    ]
  • Permissions: Elf-level security clearance required.

GET /api/people/:id

  • Description: Retrieve detailed information about a specific human by their ID.
  • Parameters:
    • id (number): The unique identifier of the human.
  • Returns: JSON object of the person’s record.
  • Example Response:
{
  "id": 1,
  "name": "Candy Cane",
  "isNice": true,
  "reason": "Helped an old lady cross the street",
  "checkedAt": "2024-12-01T10:00:00Z"
}
  • Permissions: Elf-level security clearance required.

POST /api/people

  • Description: Add a new human to the Naughty & Nice list.
  • Body:
    • name (string, required): The name of the human.
    • isNice (boolean, optional): Initial status (default: true).
    • reason (string, optional): Reason for the initial status.
  • Returns: The newly created person’s ID
  • Example Response:
{ "id": 42 }
  • Permissions: SLEIGH (Santa's List Editing and General Handling) clearance required.

PATCH /api/people/:id

  • Description: Make a judgement on a human. Naughty or nice?
  • Parameters:
    • id (number): The unique identifier of the human.
  • Body:
    • isNice (boolean, required): Official verdict.
    • reason (string, optional): Reason for the judgement.
  • Returns: { "ok": true } on success.
  • Permissions: 🚨 STRICTLY FOR USE BY SANTA ONLY 🚨 - SACK (Supreme Archival Control Keeper) clearance required.

DELETE /api/people/:id

  • Description: Remove a human from the Naughty & Nice list (for exceptional cases only).
  • Parameters:
    • id (number): The unique identifier of the human.
  • Returns: { "ok": true } on success.
  • Permissions: DELETE (Data Erasure and Ledger Editing Taskforce Executive) clearance required.

Section 2: Infraction Management

(aka the Naughty Behavior Registry)

These endpoints handle the recording of naughty behaviors, in case further judgement is needed.

GET /api/people/:id/infractions

  • Description: View the naughty deeds recorded against a specific human.
  • Parameters:
    • id (number): The unique identifier of the human.
  • Returns: JSON array of infractions.
  • Example Response:
[
  {
    "id": 5,
    "personId": 17,
    "description": "Stole cookies from the cookie jar",
    "severity": 3,
    "occurredAt": "2024-11-30T15:30:00Z"
  },
  ...
]
  • Permissions: Elf-level security clearance required.

POST /api/people/:id/infractions

  • Description: Record a new infraction against a human.
  • Parameters:
    • id (number): The unique identifier of the human.
  • Body:
    • description (string, required): Description of the naughty deed.
    • severity (number, optional): Severity level from 1 (minor) to 5 (coal-worthy). (default: 1)
  • Returns: The ID of the newly created infraction.
  • Example Response:
{ "id": 38 }
  • Permissions: SCROOGE (Santa's Comprehensive Recorders Of Overtly Grievous Events) clearance required.

Section 3: Appeal Management

(aka The JINGLE Database)

These endpoints allow recording of humans’ appeals of their recorded infractions to the JINGLE (Judicial Intervention and Nice-list Granting Logic Engine) database, for elf entertainment Santa’s reconsideration.

POST /api/appeals

  • Description: Submit a received appeal for a recorded infraction.
  • Body:
    • personId (number, required): The unique identifier of the human who lodged the appeal.
    • infractionId (number, required): The unique identifier of the infraction being appealed.
    • appealText (string, required): The human’s desperate plea for mercy.
  • Returns: The ID of the newly created appeal.
  • Example Response:
{ "id": 15 }
  • Permissions: HAPRE (Holiday Adjudication and Petition Review Executive) clearance required.

[!WARNING] Elves may find the content of appealText emotionally distressing. Or downright hilarious.

GET /api/appeals/pending

  • Description: Retrieve all pending appeals awaiting Santa’s judgement.
  • Parameters: None
  • Returns: JSON array of all pending appeals.
  • Example Response:
[
  {
    "id": 15,
    "personId": 5,
    "infractionId": 28,
    "appealText": "I swear I was just borrowing the cookies!",
    "status": 0,
    "submittedAt": "2024-12-02T12:00:00Z"
  }
]
  • Permissions: Elf-level security clearance required.

PATCH /api/appeals/:id/review

  • Description: Lodge the final decision on a pending appeal.
  • Parameters:
    • id (number): The unique identifier of the appeal.
  • Body:
    • approved (boolean, required): Santa’s final decision on the appeal.
  • Returns: { "ok": true } on success.
  • Permissions: 🚨 STRICTLY FOR USE BY SANTA ONLY 🚨 - SUPREME (Santa's Ultimate Petition Review and Evaluation Management Execution) clearance required.

Conclusion: In Closing (Please Stop Touching Things)

This API exists to ensure that all human behavior is properly observed, documented, judged, and re-judged (and occasionally laughed at in the break room). Treat it with the respect due to any system that directly controls coal distribution.

Remember:

  • If it’s not in the system, it didn’t happen.
  • If it is in the system and wrong, that’s still on you.
  • If Santa is involved, you’ve already gone too far.

Always operate within your assigned clearance level. Curiosity is festive; unauthorized access is not. Any elf caught “just testing something in production” will be reassigned to Emergency Tinsel Detangling (Level 3).

Thank you for your continued service to holiday order, moral accountability, and the smooth operation of Christmas.

[!NOTE] 🎄 End of official S. GIFT INC. manual🎄

About

Haxmas Day 4 - a Naughty or nice API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published