hackathon-starter icon indicating copy to clipboard operation
hackathon-starter copied to clipboard

Cookie Parser Middleware

Open tbonz opened this issue 10 years ago • 4 comments

@sahat can you explain the need for the cookie parser middleware? It's my understanding that express session no longer uses this as of 1.5.0 (https://github.com/expressjs/session#cookie-options), and is not needed to implement passport or other session stores. I could not see where the cookie parser middleware was being used in the application. Possibly you would able to prune this from the current dependencies.

tbonz avatar Mar 15 '16 04:03 tbonz

Ah you may be right. I have been copy and pasting these middlewares from other sites when I built hackathon-starter. I will remove it since it is not being used for anything in particular.

Update: Actually it makes sense - express-session v1.5 came out about 6 months after hackathon-starter was built.

sahat avatar Mar 15 '16 16:03 sahat

.. one other item I was looking at while refactoring was the method override middleware. It's possible this could be pruned too. Let me know what you think. Since express 4 the app object allows you to route via app.get, app.post, app.put, app.delete.. and so I'm not clear how the method override middleware would be needed. Like you mention, maybe it just got copy/pasted from another project when setting up?

tbonz avatar Mar 15 '16 17:03 tbonz

Ah good question. I was actually working on that a few days ago on my upcoming boilerplate project. https://github.com/sahat/boilerplate/blob/master/generators/authentication/modules/common/views/profile.jade#L16

I am not using it in this project, but the idea is you can have REST routes while still using <form> which only supports GET and POST. That's why in hackathon-starter I am using non-RESTroutes like POST /account/password and /account/profile to update data (where PUT is more appropriate). The same goes for deleting an account. Could be DELETE /account instead of POST /account/delete.

So I could either remove method-override, or update routes to use it like you see in the link above, conforming to REST API.

sahat avatar Mar 15 '16 17:03 sahat

The boilerplate project looks great! Can't wait to see when it's finished.

I enjoy the simplicity of hackathon starter, and so my vote would be to remove the method override middleware making it less complicated to understand when first starting a project. However, I also see the benefits of updating the routes and creating actual REST routes.

Tough decision, so I'll leave it up to you to decide if updating the routes makes more sense for this project or not.

tbonz avatar Mar 15 '16 17:03 tbonz