Skip to content

Conversation

@AFatmaa
Copy link

@AFatmaa AFatmaa commented Oct 14, 2025

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

This PR adds two small Express applications for the Decomposition prep task.

  • The first app includes two custom middlewares:

    1. Extract username from request header
    2. Validate JSON array in POST body
  • The second app replaces one custom middleware with the built-in express.json() middleware.
    It parses JSON automatically.

Questions

I don’t have any questions. Thank you.

@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Wrong number of parts separated by |s

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@AFatmaa AFatmaa added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 14, 2025
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Wrong number of parts separated by |s

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

1 similar comment
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Wrong number of parts separated by |s

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@AFatmaa AFatmaa changed the title London | 25-SDC-July | Fatma Arslantas | Module-Decomposition | Sprint 3 | Middleware exercises London | 25-SDC-July | Fatma Arslantas | Sprint 3 | Middleware exercises Oct 14, 2025
@github-actions
Copy link

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

4 similar comments
@github-actions
Copy link

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, though I have a suggestion of something to think about to help improve the reusability of the middleware you have written

return res.status(400).send("Error: Body must be a JSON array.");
}

const allStrings = parsed.every((item) => typeof item === "string");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the goal of this middleware - it seems to do two things.

Here you're combining JSON parsing and checking the input is strings. As middleware aims to allow re-use of code, what change could you make to this that would allow you to re-use these separate checks more easily?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LonMcGregor,

You're right! This middleware was handling two responsibilities: parsing JSON and validating that the input is a string array.
Middleware should ideally do one specific job, so I refactored it into two separate middlewares: one for JSON parsing and another for string validation.
This makes the code cleaner and easier to reuse in other routes.

Thank you for your feedback 🌸

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 28, 2025
@AFatmaa
Copy link
Author

AFatmaa commented Nov 9, 2025

Hi @LonMcGregor,

Thank you for the suggestion! 🙌
I’ve made the changes and separated the logic into two middlewares to improve reusability.
Could you please take a look and let me know if everything looks good now?

@AFatmaa AFatmaa added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 9, 2025
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, well done

@LonMcGregor LonMcGregor added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 10, 2025
@AFatmaa
Copy link
Author

AFatmaa commented Nov 10, 2025

Thank you @LonMcGregor 🤗

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

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Decomposition The name of the module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants