It would be definitely possible, but I am not aware of any implementation yet. The reason Redis and MongoDB are chosen is because they are faster and simpler to set up than MySQL, for data set like user sessions.
You can initialize the session in the login route. Check if the user submitted the proper creds, and initialize the session accordingly.
You can check if a session has ended by looking at session variables, which are expected to be there. If they are not present, there is no session.
Ah, yes! I made the classic mistake of assuming the readers know would. Making a post to clarify it. Thanks!
Not really errata, it is a common practice for instantiating a class which does not require any arguments. If JSLint does not give you an option for making this optional, you could try JSHint – http://www.jshint.com/ – it is the more customizable fork of JSLint.
Will definitely try to cover the topic a little later. Thanks for the suggestion.
Most welcome!
Noted and updated on the Forum.
Thanks for reporting.
The example on Page no. 201 is a complete example using an Express app.
Errata. Thanks for reporting.
MemoryStore is used for storing session data by default, which uses the app process’ memory. Since cluster processes can’t share session data, they will all be working with their own individual copies of session. This will result in a very erratic behavior from the app.
The workaround is to use an external memory store like RedisStore or MongoStore. You can read the details on page 184-185.
Welcome to the forums, Avinash. Glad you found what you were looking for!
Hi Chris,
Check out Restify for a API-specific HTTP service module.
People use REST and RESTful in varying degrees of ‘RESTness’, I am not quite sure which degree you are coming from. Read this interesting article, “Your API is not RESTful“, to get the context.
Implementing a truly and wholly RESTful API in any platform is going to be a substantial effort. However, resourceful routing (Chapter 3, page 73) is very REST-like. You can secure it by the use of session or API token, depending on the nature of your client.
All the best!
Yaapa