https://github.com/sandeepguptax2003/zarektronix-jokes
https://github.com/sandeepguptax2003/zarektronix-jokes
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sandeepguptax2003/zarektronix-jokes
- Owner: sandeepguptax2003
- Created: 2023-12-02T03:40:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-02T10:15:58.000Z (over 1 year ago)
- Last Synced: 2025-02-01T22:47:55.132Z (4 months ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Joke API Command Line Tool
## Description
This command line tool interacts with the "icanhazdadjoke" API to fetch and display jokes based on user-defined search terms. Additionally, it provides functionality to save jokes for future laughs and showcases the most popular joke in a leaderboard format.## Requirements
- Node.js
- fs module (for file reading and writing)
- process module (for command line arguments)
- request module (for making API requests)## Features
- **Search Jokes**: Allows users to search for jokes based on a given search term.
- **Random Joke Display**: Displays a random joke fetched from the API matching the search term.
- **Saving Jokes**: Saves the selected joke to a 'jokes.txt' file for future amusement.
- **Error Handling**: Provides witty error messages when no jokes are found for the search term.
- **Leaderboard**: Implements a feature to display the most popular joke stored in 'jokes.txt' with the number of laughs it received.## Example
To run the tool, use the following command:1. Search for a Joke:
node joke-cli.js [searchTerm]2. View Leaderboard:
node joke-cli.js [leaderboard]## Usage
searchTerm: Search for jokes based on the provided term (e.g., `node jokeTool.js unicorn`).
leaderboard: Display the most popular joke stored in the 'jokes.txt' file.## Code Overview
The code contains functions to interact with the API, handle file operations, display random jokes, and manage the leaderboard feature. It's organized into modular functions for ease of understanding and maintenance.