Hi “NotJustTheMeatGuy” here.

 

I haven’t been posting lately and I am truly sorry for that. This week has been the start of “Back-end Web Development“. It is also called server-side development but if you don’t know what back-end or server-side development is click the link. We have been working with “Node.js” to build our own servers and it has been really fun, exciting but also challenging. I am happy to be learning a new technology but it is very difficult for me to grasp the concepts of the backend. I have gotten better but I am still a novice. Along with node.js we have have worked with the Express framework and the Mustache template engine. And yes I did say Mustache lol.

 

 

 

 

Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. It is the most popular nodejs framework out there along with Koa and Hapi. I don’t know much about the the other two but I know they still have a good following around them.

 

 

Mustache is a template engine that can be used for HTML, config files and source code but I only know of it to be used in HTML. It works by expanding tags in a template using values provided in a hash or object. All of this has been hard to comprehend when you first start out, well at least for me. Learning to think logically may seem easy when you think about it but when you try to put it into practice you see how hard it really is. I am on my way to understanding it but for me it may take some time but I will get there.

 

 

I had a hard time with JavaScript also but now I feel confident in using it in an application, well as long as it not too deep even so google is a wonderful tool at my disposal and so do you all. Once you start learning node you learn about the frameworks, templates, middleware and everything outside and in. It is a lot but has to be done, you don’t have to know everything but being at least familiar with some of these things is good enough for a Jr Developer position. I hope to be more than just a Jr some day and I will work hard to do so. I still have a lot to learn because we still haven’t gotten into databases and well that shouldn’t be to hard right?

 

 

Well thats the gist of what I have been learning all week but let me show you how to create a basic server application.

“Wow Andrew Really that is awesome!”

I will try to explain each piece of code as I write it but I encourage you all to go out and learn on your on and don’t forget GOOGLE is a very viable tool.

Well lets get started shall we.

First we have to have Node.js installed. The link will take you to the page that has installation for each OS. Alternatively you could install Visual Studio Code and have it built in.

Inside the terminal

mkdir – express-app //make a folder called express-app

cd into ‘express-app’ directory //go into the express-app folder

npm init and except all default options //adds json file

npm install //adds node modules

touch server.js //create a file called server.js

npm install express –save //adds the express module

Inside the server.js file

//loads the express module

const express = require(‘express’);

//putting express in a variable will allow you to call it in the file

const application = express();

//listens on root and serves Hello World! from root

app.get(‘/’, function (request, respond) {

response.send(‘Hello World!’);

});
//accesses file on port 3000

app.listen(3000, function () {
console.log(‘Successfully started express application!’)
});

In your terminal type in node server.js to start your sever and
Finally open a new tab and type in localhost:3000

There you go you have made a sever.

Well till next time this has been
“NotJustTheMeatGuy”

 

 

It's only fair to share...Share on FacebookShare on Google+Share on LinkedInShare on TumblrTweet about this on TwitterShare on Reddit