Skip to content

London | 26-SDC-Mar | Ebrahim Beiati-Asl | Sprint 3 | Sprint3 middleware#76

Open
ebrahimbeiati wants to merge 23 commits into
CodeYourFuture:mainfrom
ebrahimbeiati:sprint3-middleware
Open

London | 26-SDC-Mar | Ebrahim Beiati-Asl | Sprint 3 | Sprint3 middleware#76
ebrahimbeiati wants to merge 23 commits into
CodeYourFuture:mainfrom
ebrahimbeiati:sprint3-middleware

Conversation

@ebrahimbeiati

Copy link
Copy Markdown

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

Sprint 3 middleware

@ebrahimbeiati ebrahimbeiati added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Decomposition The name of the module. labels Mar 30, 2026

@LonMcGregor LonMcGregor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did you intent to commit the chat app files here?

Good work on this, I have a few comments though

export default function usernameMiddleware(req, res, next) {
const username = req.headers["x-username"];

req.username = username ?? null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it ok to continue with "null" as a username?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, returning null here is intentional. It allows the rest of the app to distinguish between:

a user who did provide an x-username header

and a user who did not authenticate

The main route checks this value and outputs either an authenticated or unauthenticated message, so null is a safe and explicit fallback.

Comment thread middleware-custom/app.js
} else {
subjectMessage = `You have ${count} subjects: ${list}.`;
}
res.send(`${authMessage} ${subjectMessage}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What should the program output as a subject message if the authentication failed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

If authentication fails, I still show the subject message on purpose so the user gets feedback about the subjects they sent.

@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 Jul 1, 2026
@ebrahimbeiati ebrahimbeiati 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 Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Decomposition The name of the module. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants