Skip to content

Conversation

@Maryyy-ux
Copy link

Commit changes master_main
Updated with description and Render link
Copy link
Contributor

@HIPPIEKICK HIPPIEKICK left a 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?

Comment on lines +50 to +83
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) => {
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants