-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maryyy_ux_project-mongo-API #515
base: master
Are you sure you want to change the base?
Conversation
Commit changes master_main
Updated with description and Render link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get "Service unavailable" on your deployed link, can you please have a look?
app.get("/shows/search", async (req, res) => { | ||
const { title, type, country } = req.query; | ||
const query = {}; | ||
|
||
if (title) { | ||
query.title = new RegExp(title, "i"); | ||
} | ||
if (type) { | ||
query.type = type; | ||
} | ||
if (country) { | ||
query.country = country; | ||
} | ||
|
||
try { | ||
const shows = await Netflix.find(query); | ||
res.status(200).json(shows); | ||
} catch (err) { | ||
res.status(500).json({ error: "Failed to fetch shows", details: err.message }); | ||
} | ||
}); | ||
|
||
// Example stats route | ||
app.get("/shows/stats", async (req, res) => { | ||
try { | ||
const count = await Netflix.countDocuments(); | ||
res.status(200).json({ totalShows: count }); | ||
} catch (err) { | ||
res.status(500).json({ error: "Failed to fetch stats", details: err.message }); | ||
} | ||
}); | ||
|
||
// Get all shows with pagination | ||
app.get("/shows", async (req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three could all just be one endpoint called /shows. Then you can use different query params to filter on specific things
https://maryyy-ux-project-mongo-api.onrender.com