diff --git a/.gitignore b/.gitignore index 051dd08..726fe14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .prettierignore -.idea \ No newline at end of file +.idea +package-lock.json \ No newline at end of file diff --git a/index.js b/index.js index 2105394..4f4b1f8 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,7 @@ const available_cards = { "/word-of-the-day-card": require("./src/cards/word_of_the_day"), "/challenge-of-the-week-card": require("./src/cards/challenge-of-the-week"), "/team-work-quote-card" : require("./src/cards/team-work-quote"), + "/breaking-bad-quote-card" : require("./src/cards/breaking-bad-quotes"), "/bhagavad-geeta-card" : require("./src/cards/bhagavad-geeta-quotes"), "/programming-facts-card": require("./src/cards/programming-facts"), "/spanish-quote-card": require("./src/cards/spanish-quote"), diff --git a/src/cards/breaking-bad-quotes.js b/src/cards/breaking-bad-quotes.js new file mode 100644 index 0000000..1cde175 --- /dev/null +++ b/src/cards/breaking-bad-quotes.js @@ -0,0 +1,48 @@ +const express = require("express"); +const router = express.Router(); +const fs = require("fs").promises; +const { generateCard, CARD_AGE, Languages } = require("../card-generator"); +const { parseOptions } = require("../options-parser"); + +const DATA_FILE_PATH = "./src/data/breaking-bad-quotes.json"; +const DEFAULT_THEME = "dark_2"; + +const handleTheme = (req, res, next) => { + req.theme = req.query.theme || DEFAULT_THEME; + next(); +}; + +const handleOptions = (req, res, next) => { + if (req.theme === "custom") { + req.options = parseOptions(req.query); + } + next(); +}; + +router.get("/", handleTheme, handleOptions, async (req, res) => { + try { + const breakingbadQuotesData = JSON.parse( + await fs.readFile(DATA_FILE_PATH, "utf8") + ); + const randomQuote = breakingbadQuotesData[Math.floor(Math.random() * breakingbadQuotesData.length)]; + const quoteContent = `"${randomQuote.quote}"\n\nAuthor- ${randomQuote.author}`; + + const quoteCard = await generateCard( + quoteContent, + req.theme, + req.options, + Languages.ENGLISH + ); + + res.writeHead(200, { + "Content-Type": "image/svg+xml", + "Cache-Control": `public, max-age=${CARD_AGE}`, + }); + res.end(quoteCard); + } catch (error) { + console.error("Error:", error); + res.status(500).send("Internal Server Error"); + } +}); + +module.exports = router; diff --git a/src/data/breaking-bad-quotes.json b/src/data/breaking-bad-quotes.json new file mode 100644 index 0000000..ec48752 --- /dev/null +++ b/src/data/breaking-bad-quotes.json @@ -0,0 +1,502 @@ +[ + { + "index": 1, + "quote": "Walter Jr., you're my big man. There are going to be some things that you'll come to learn about me in the next few days. But just know that no matter how it may look, I only had you in my heart. Goodbye!", + "author": "Walter White" + }, + { + "index": 2, + "quote": "Do what you're gonna do.", + "author": "Hank Schrader" + }, + { + "index": 3, + "quote": "I want my kids back. I want my life back. Please tell me – How much is enough? How big does this pile have to be?", + "author": "Skyler White" + }, + { + "index": 4, + "quote": "It can be done exactly how I want it. The only question is: Are you the man to do it? Figure it out. That's what I'm paying you for.", + "author": "Walter White" + }, + { + "index": 5, + "quote": "I am the man that I am son, and there's plenty that I would change about that but, here we are and this is just what it is.", + "author": "Walter White" + }, + { + "index": 6, + "quote": "Never say never", + "author": "Saul Goodman" + }, + { + "index": 7, + "quote": "Moral of the story is: I chose a half measure when I should have gone all the way. I'll never make that mistake again. No more half measures, Walter.", + "author": "Mike Ehrmantraut" + }, + { + "index": 8, + "quote": "Send him to Belize? I'll send YOU to Belize.", + "author": "Walter White" + }, + { + "index": 9, + "quote": "I'm sorry, what were you asking me? Oh, yes, that stupid plastic container I asked you to buy. You see, hydrofluoric acid won't eat through plastic; it will however dissolve metal, rock, glass, ceramic. So there's that.", + "author": "Walter White" + }, + { + "index": 10, + "quote": "Right now, what I need, is for you to climb down out of my ass. Can you do that? Will you do that for me honey? Will you please, just once, get off my ass? You know? I'd appreciate it. I really would.", + "author": "Walter White" + }, + { + "index": 11, + "quote": "Being the best at something is a very rare thing. You don't just toss something like that away. And what, you wanna squander that potential?", + "author": "Walter White" + }, + { + "index": 12, + "quote": "Cooking is art. And the shit I cook is the bomb.", + "author": "Jesse Pinkman" + }, + { + "index": 13, + "quote": "I do not believe fear to be an effective motivator. I want investment. For now, I'm simply interested in time frame.", + "author": "Gustavo Fring" + }, + { + "index": 14, + "quote": "You need to stop focusing on the darkness behind you. The past is the past. Nothing can change what we’ve done.", + "author": "Walter White" + }, + { + "index": 15, + "quote": "Ignorance of the law doesn't equate to criminality. It equates to ignorance.", + "author": "Skyler White" + }, + { + "index": 16, + "quote": "Did you just bring a bomb into a hospital?", + "author": "Jesse Pinkman" + }, + { + "index": 17, + "quote": "You're never too old for balloons.", + "author": "Mike Ehrmantraut" + }, + { + "index": 18, + "quote": "I did it for me. I liked it. I was good at it. And I was really... I was alive.", + "author": "Walter White" + }, + { + "index": 19, + "quote": "I am not in danger, Skyler. I AM the danger!", + "author": "Walter White" + }, + { + "index": 20, + "quote": "Don't drink and drive but if you do, call me.", + "author": "Saul Goodman" + }, + { + "index": 21, + "quote": "Say my name.", + "author": "Walter White" + }, + { + "index": 22, + "quote": "Yeah, science!", + "author": "Jesse Pinkman" + }, + { + "index": 23, + "quote": "You know, you all know exactly who I am. Say my name.", + "author": "Walter White" + }, + { + "index": 24, + "quote": "You either run from things, or you face them, Mr. White.", + "author": "Jesse Pinkman" + }, + { + "index": 25, + "quote": "I'm in the empire business.", + "author": "Walter White" + }, + { + "index": 26, + "quote": "No matter what happens, no more bloodshed.", + "author": "Gustavo Fring" + }, + { + "index": 27, + "quote": "I’ve still got things left to do.", + "author": "Walter White" + }, + { + "index": 28, + "quote": "I will kill your wife, I will kill your son, I will kill your infant daughter.", + "author": "Gustavo Fring" + }, + { + "index": 29, + "quote": "Yeah Mr. White! Yeah, science!", + "author": "Jesse Pinkman" + }, + { + "index": 30, + "quote": "You clearly don’t know who you’re talking to, so let me clue you in. I am not in danger, Skyler. I am the danger.", + "author": "Walter White" + }, + { + "index": 31, + "quote": "You are a time bomb, tick-tick-ticking. And I have no intention of being around for the boom.", + "author": "Saul Goodman" + }, + { + "index": 32, + "quote": "I’m not in the meth business. I’m in the empire business.", + "author": "Walter White" + }, + { + "index": 33, + "quote": "Shut up! Shut up! Shut up!", + "author": "Skyler White" + }, + { + "index": 34, + "quote": "I watched Jane die.", + "author": "Walter White" + }, + { + "index": 35, + "quote": "If you believe that there’s a hell, I don’t know if you’re into that. But we’re already pretty much going there, right?", + "author": "Jesse Pinkman" + }, + { + "index": 36, + "quote": "I did it for me. I liked it.", + "author": "Walter White" + }, + { + "index": 37, + "quote": "We’re done when I say we’re done.", + "author": "Walter White" + }, + { + "index": 38, + "quote": "It’s over when I say it’s over.", + "author": "Walter White" + }, + { + "index": 39, + "quote": "Run.", + "author": "Walter White" + }, + { + "index": 40, + "quote": "You can’t sell millions of dollars of meth without breaking a few eggs.", + "author": "Walter White" + }, + { + "index": 41, + "quote": "I am the one who knocks!", + "author": "Walter White" + }, + { + "index": 42, + "quote": "You know, I'm not really a 'work for free' kind of guy.", + "author": "Saul Goodman" + }, + { + "index": 43, + "quote": "What’s the point of being an outlaw when you got responsibilities?", + "author": "Jesse Pinkman" + }, + { + "index": 44, + "quote": "We’re done when I say we’re done.", + "author": "Walter White" + }, + { + "index": 45, + "quote": "I did it for me. I liked it. I was good at it. And I was really... I was alive.", + "author": "Walter White" + }, + { + "index": 46, + "quote": "You’re the smartest guy I ever met. And you’re too stupid to see he made up his mind ten minutes ago.", + "author": "Hank Schrader" + }, + { + "index": 47, + "quote": "I don’t know what’s wrong with me, Mr. White. I’m just so... I’m so sorry.", + "author": "Jesse Pinkman" + }, + { + "index": 48, + "quote": "The moral of the story is I chose a half measure, when I should have gone all the way.", + "author": "Mike Ehrmantraut" + }, + { + "index": 49, + "quote": "You all know exactly who I am. Say my name.", + "author": "Walter White" + }, + { + "index": 50, + "quote": "You can’t keep getting away with this!", + "author": "Jesse Pinkman" + }, + { + "index": 51, + "quote": "No more half-measures.", + "author": "Mike Ehrmantraut" + }, + { + "index": 52, + "quote": "You know, you all know exactly who I am. Say my name.", + "author": "Walter White" + }, + { + "index": 53, + "quote": "I have nothing left to lose.", + "author": "Walter White" + }, + { + "index": 54, + "quote": "Do you know how much I make a year?", + "author": "Walter White" + }, + { + "index": 55, + "quote": "If you don’t know who I am, then maybe your best course would be to tread lightly.", + "author": "Walter White" + }, + { + "index": 56, + "quote": "All I can do is wait for the cancer to come back.", + "author": "Walter White" + }, + { + "index": 57, + "quote": "We’re done when I say we’re done.", + "author": "Walter White" + }, + { + "index": 58, + "quote": "The moral of the story is I chose a half measure, when I should have gone all the way.", + "author": "Mike Ehrmantraut" + }, + { + "index": 59, + "quote": "Say my name.", + "author": "Walter White" + }, + { + "index": 60, + "quote": "You clearly don’t know who you’re talking to, so let me clue you in. I am not in danger, Skyler. I am the danger.", + "author": "Walter White" + }, + { + "index": 61, + "quote": "I chose a half measure when I should have gone all the way.", + "author": "Mike Ehrmantraut" + }, + { + "index": 62, + "quote": "It’s over when I say it’s over.", + "author": "Walter White" + }, + { + "index": 63, + "quote": "You’re trouble. I’m trouble.", + "author": "Jesse Pinkman" + }, + { + "index": 64, + "quote": "This is my own private domicile, and I will not be harassed…b****!", + "author": "Jesse Pinkman" + }, + { + "index": 65, + "quote": "I did it for me. I liked it. I was good at it.", + "author": "Walter White" + }, + { + "index": 66, + "quote": "All the lies, I can't even keep them straight anymore.", + "author": "Skyler White" + }, + { + "index": 67, + "quote": "Some people are immune to good advice.", + "author": "Saul Goodman" + }, + { + "index": 68, + "quote": "I know what happens if I don’t.", + "author": "Gustavo Fring" + }, + { + "index": 69, + "quote": "You got me. I’m in the empire business.", + "author": "Walter White" + }, + { + "index": 70, + "quote": "The moral of the story is I chose a half measure, when I should have gone all the way.", + "author": "Mike Ehrmantraut" + }, + { + "index": 71, + "quote": "I am not in danger, Skyler. I am the danger.", + "author": "Walter White" + }, + { + "index": 72, + "quote": "I trust the hole in the desert I’d leave you in.", + "author": "Mike Ehrmantraut" + }, + { + "index": 73, + "quote": "You’re my free pass.", + "author": "Jesse Pinkman" + }, + { + "index": 74, + "quote": "I didn’t marry a criminal lawyer. I married a lawyer who’s a criminal.", + "author": "Skyler White" + }, + { + "index": 75, + "quote": "I’m not a hero. I’m a coward.", + "author": "Walter White" + }, + { + "index": 76, + "quote": "You don’t need a criminal lawyer. You need a criminal lawyer.", + "author": "Saul Goodman" + }, + { + "index": 77, + "quote": "When the going gets tough, you don’t want a criminal lawyer. You want a criminal lawyer.", + "author": "Saul Goodman" + }, + { + "index": 78, + "quote": "You think I came all this way just to let something as trivial as the truth get in the way?", + "author": "Saul Goodman" + }, + { + "index": 79, + "quote": "I was alive.", + "author": "Walter White" + }, + { + "index": 80, + "quote": "You got me. I’m in the empire business now.", + "author": "Walter White" + }, + { + "index": 81, + "quote": "You either run from things, or you face them.", + "author": "Jesse Pinkman" + }, + { + "index": 82, + "quote": "I’m not in this for money. I’m in this for me.", + "author": "Walter White" + }, + { + "index": 83, + "quote": "Family is everything.", + "author": "Walter White" + }, + { + "index": 84, + "quote": "It’s not about money, it’s about power.", + "author": "Walter White" + }, + { + "index": 85, + "quote": "I’m not a monster. I’m just ahead of the curve.", + "author": "Walter White" + }, + { + "index": 86, + "quote": "I just wanted to say that you’re a time bomb, tick-tick-ticking, and I have no intention of being around for the boom.", + "author": "Skyler White" + }, + { + "index": 87, + "quote": "I did it for my family.", + "author": "Walter White" + }, + { + "index": 88, + "quote": "I watched Jane die.", + "author": "Walter White" + }, + { + "index": 89, + "quote": "My name is ASAC Schrader, and you can go f*** yourself.", + "author": "Hank Schrader" + }, + { + "index": 90, + "quote": "What the hell is wrong with you? We’re a family!", + "author": "Skyler White" + }, + { + "index": 91, + "quote": "Jesse, you asked me if I was in the meth business or the money business. Neither. I’m in the empire business.", + "author": "Walter White" + }, + { + "index": 92, + "quote": "I have nothing to lose anymore.", + "author": "Jesse Pinkman" + }, + { + "index": 93, + "quote": "Look at me! I’m the one who knocks!", + "author": "Walter White" + }, + { + "index": 94, + "quote": "I am the one who knocks.", + "author": "Walter White" + }, + { + "index": 95, + "quote": "To hell with your cancer. I’ve been living with cancer for twenty years.", + "author": "Marie Schrader" + }, + { + "index": 96, + "quote": "I’d rather not live in a world without Coca-Cola.", + "author": "Gustavo Fring" + }, + { + "index": 97, + "quote": "I’m not in danger, I am the danger.", + "author": "Walter White" + }, + { + "index": 98, + "quote": "What good is being an outlaw when you have responsibilities?", + "author": "Jesse Pinkman" + }, + { + "index": 99, + "quote": "You know why I do this. I do this for my family.", + "author": "Walter White" + }, + { + "index": 100, + "quote": "You don't need a criminal lawyer. You need a criminal lawyer.", + "author": "Saul Goodman" + } +] diff --git a/src/help.js b/src/help.js index 91c54d5..737bf0c 100644 --- a/src/help.js +++ b/src/help.js @@ -164,6 +164,15 @@ router.get("/", (req, res) => { example: [`${baseurl}/team-work-quote-card`], }, }, + "breaking-bad-quote-card": { + info: "Generate random motivational quote related to the breaking bad.", + api: { + args: { + theme: "Theme of card. All themes. Default: dark_2 [Optional]", + }, + example: [`${baseurl}/breaking-bad-quote-card`], + }, + }, "bhagavad-geeta-card": { info: "Generate a random quote from the bhagavad-geeta-card", api: {