PureCode Software interview question

How would you implement user authentication middleware in a Node.js application?