Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]
});
});

Expand Down Expand Up @@ -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}`);
Expand Down