Choosing the proper starting point
I took a look at the basic information about Node and I found that it can react to the client HTTP requests without any web server daemon between the code and the user. Wonderful, but this also means that you have to handle the whole request acting as a server. You have to decide what should you do with the request for /homepage/ and what to do with the request for /login/ page. I’m not talking about the page business logic itself, I’m talking about handling the request before it will be sent to the particular piece of code to be processed. I don’t want to deal with this. Fortunately, there is a solution, not even one, but I chose Express which is described as web application framework for Node.js. It can handle routing (sending particular URLs to the particular pieces of code), static content delivery, error handling and much more. Beautiful, I thought, this is a good starting point for me.
Next choices to come
After few dozens of minutes spent on investigations I’m still not sure which one I want to use. I can not see the ideal candidate, but what I’m sure is that pug and jade are not my favorites because they are using their own notation for HTML elements – I’m not sure if I can handle that much right now. It’s hard to tell which one is “industry standard” or which one is mostly used. Most likely I will stay with EJS or HBS which is short for Handlebars as far as I can tell. They look fine for me for now. Will I regret my decision in the future?
Maybe the best solution for me will be to find a proper boilerplate website and start on such a foundation? There are few of them listed in the Express wiki on GitHub. One more hour spent on reviewing them and I’m sure that this is too much for me for now. They are prepared for someone who already knows what to look for. There are solutions chosen by the authors of these and I’m not sure if the same is good for me. It looks like I will have to learn much more than I expected. How to handle sessions, how to deal with secured and public content, how to persist the data in the database…
Is Mongo the only choice?
Looking at various tutorials, boilerplate websites, and sample projects on GitHub I came to the conclusion that there is nothing but Mongo when talking about a database for Node. I don’t want to say that you have no choice. There are libraries to connect to all main SQL database engines. The problem is that majority of examples and tutorials is based on Mongo. In my first application, however, I don’t want to use NoSQL database. An amount and type of data I want to compare are not well suitable for NoSQL solutions I guess. Maybe I’m wrong but I want to start without one more new thing to learn and to install. MySQL is my database of choice because on the server I want to use, it is already running.
This was a busy day. I spend few hours in total digging in various places trying to find answers for beginners questions. I decided to start small and simple site using Express generator and just try to handle other problems once I will reach them. Wish me luck 🙂