diff --git a/app.js b/app.js index d4056d9..03d1083 100644 --- a/app.js +++ b/app.js @@ -10,7 +10,14 @@ app.get('/', (req, res) => { res.json({ message: 'Welcome to the Sample Web App 🎉', description: 'A Node.js + Express server running on port 3000', - routes: ['/api/data', '/api/users', '/api/products', '/api/status', '/api/time'] + routes: [ + '/api/data', + '/api/users', + '/api/products', + '/api/status', + '/api/time', + '/api/quotes' + ] }); }); @@ -71,6 +78,25 @@ app.get('/api/time', (req, res) => { }); }); +// 6️⃣ Quotes API +app.get('/api/quotes', (req, res) => { + const quotes = [ + "Believe you can and you're halfway there.", + "Success is not the key to happiness. Happiness is the key to success.", + "The future depends on what you do today.", + "Don’t watch the clock; do what it does. Keep going.", + "Hard work beats talent when talent doesn’t work hard." + ]; + + const randomQuote = quotes[Math.floor(Math.random() * quotes.length)]; + + res.json({ + quote: randomQuote, + totalQuotes: quotes.length, + source: 'Random Quote API' + }); +}); + // Start server app.listen(PORT, () => { console.log(`✅ Server running at http://localhost:${PORT}`);