How to structure a Node, Express, Connect-Auth and Backbone application on the server-side?

前端 未结 1 1432
孤街浪徒
孤街浪徒 2021-01-30 15:39

I\'m a client-side guy that just stepped into the world of server-side javascript. I\'ve got this idea about how I think I want to build my first Nodejs application. I want a se

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 16:04

    I think you have the right idea, although I'll throw out a couple of thoughts:

    • Defining Routes - If you are defining a lot of routes, especially with JSON, you may want to define them dynamically via an MVC type framework. You can find a good example of that in the express samples here. It would save you a lot of handwritten routes and you could pass node objects back to the client as JSON without doing much else on the server side.
    • Backbone on the Server - If you want to go a little crazier (and I have not ever used this technique), Development Seed have built a framework called bones that uses backbone on the server side.
    • Login Example - There is a good tutorial over at DailyJS regarding user session management.
    • Accessibility - As long as you don't have accessibility concerns, providing data via a REST API makes sense. If you have to worry about 508 compliance or other javascript limitations you might run into problems.

    As for security, setting your session timeout to a lower value and choosing an appropriate secret key would probably go a long way toward making sure someone can't generate session cookies (by default the actual data isn't stored on the client). I'm not sure what algorithm node.js uses to generate session cookies. Here are some details on the express session middleware.

    0 讨论(0)
提交回复
热议问题