Hello World
Last updated: 4 - 5 - 2019

We'll see how to make a simple "Hello World" website with ZinkyJS.

Install zinky-cli

To make things simpler and faster, ZinkyJS has developed a CLI tool that we'll be using for this tutorials. So let's install it!

To do that, open the terminal and run this command:

sudo npm install -g zinky-cli

Generate Application

Now that zinky-cli is installed, we can generate our app.

In the terminal, navigate to the folder where you want to put your website, and run this command

zinky -a appname

You will note that a new folder named "appname" was created containing our newly generated app.

Navigate into it:

cd appname

And install its npm dependencies, by running this command:

npm install

Application Module

ZinkyJS apps put project into separate folders representing the app modules. Each one of them contains its routes controllers, views and public files.

At the moment, the app has not yet any module, so we'll generate one called home that will handle our application home page.To perform this, run this zinky-cli command:

zinky -M home

You will see the new module's folder in "app_modules" folder.

One last thing we have to do before we'll be able to see the Hello World is to tell our homemodule to display this message.

Open app_modules/home/index.js and add the following line to GET_root method:

 res.end('Hello World');

So the file will look like:

 const Zinko = require('zinko');
class Home extends Zinko {

  GET_root(req, res) {
    res.end('Hello World');
  }

}

module.exports = Home;

See Result

We can now check the result.

Start the app by running:

node app.js

And visit localhost:3000/home/ using your browser then enjoy the result!

Next Course: Routing