Blog

Hello NodeJS | Mongoose

Using basic Mongo in our project is definitely doable but not very efficient in terms of maintainability. As you can see there’s a lot of boilerplate code required for even basic tasks as checking for a user. Mongoose is a wrapper for MongoDB that makes it a lot easier to handle database-queries
By paranerd | Sep 17, 2018

Hello NodeJS | Organizing Views

So far we only have to manage two views - no big deal. But imagine having dozens of different pages, which is not at all unusual. Having all those views in one single views-folder would be a huge mess and very difficult to manage and maintain. Therefore it’s usually better to use sub-folders to organize our views.
By paranerd | Sep 17, 2018

Hello NodeJS | Project Structure

Before we go any further, let’s have a quick look into the general structure of a NodeJS-Project. When you search the web for suggestions on that, you will be flooded with a miriad of opinions on what’s the best way to organize your code. To be honest, I don’t claim perfection for my approach.
By paranerd | Sep 17, 2018

Hello NodeJS | Sessions

Sessions are a simple way of persisting information between page requests. They make it easy to save a value in some part of your website and retrieve that value at a completely different place without having to manually send it there. A session is nothing magical, just an array of key-value-pairs saved on the server accessed by the browser via a Session-ID which is stored in a cookie.
By paranerd | Sep 17, 2018

Hello NodeJS | Templates

So far our pages have been very static, meaning we just deliver HTML without any dynamic content whatsoever. What we need is an easy way for our server to send data to the client. This is where templates come in. There are many template engines available. Some of the more popular ones are:
By paranerd | Sep 17, 2018

Hello NodeJS | The Package Manager

With the installation of the nodejs-package also came a tool called ’npm’ (Node Package Manager). We will be using this quite a bit when developing for NodeJS. For a start it helps us setting up our project properly. Now we can let the npm-magic happen: 1 npm init This will ask you for a couple of things.
By paranerd | Sep 17, 2018

Hello NodeJS | User Input

Displaying a login-screen is one thing, but it doesn’t help us all that much if we can’t process the user’s input, right?! Let’s add this feature now! First, we need to install another package that allows us to extract data from POST-requests: 1 npm install body-parser We need to include the body-parser in our server.
By paranerd | Sep 17, 2018

Hello NodeJS | Working With HTML

So far we only sent plain text to the browser. Already kind of exciting but we want to be able to serve really cool HTML, don’t we?! Let’s go do that right now! In our views/ directory we add a file called index.html: 1 2 3 4 5 6 7 8 <!
By paranerd | Sep 17, 2018

Hello NodeJSP | Hello World - The Next Level

Our first Hello World example was great and all, but while the console is extremely helpful for debugging, we actually want to put things in the browser, don’t we? So let’s do that now! To be able to access our code from a webbrowser we will need a server. The standard-server for NodeJS is ExpressJS, so that’s what we will be using as well.
By paranerd | Sep 17, 2018

How To Do The Holy Grail Layout With CSS-Grid

I already gave an introduction to what the Holy Grail layout actually is in my previous post. So in this post we’re mainly going to focus on building the exact same thing, only this time with CSS-Grids. But first, a little introduction to CSS-Grids: What are CSS-Grids? The CSS-Grid-Layout is a fairly new layout system in CSS.
By paranerd | Sep 14, 2018