Skip to content

Latest commit

 

History

History
89 lines (73 loc) · 1.58 KB

hello-world.md

File metadata and controls

89 lines (73 loc) · 1.58 KB
description
This article discusses the basic steps to building a simple hello-world project with a hyron

Hello world

{% hint style="info" %} you can clone & run this example on github : https://github.com/thangdjw/hyron-helloworld {% endhint %}

Step 1 : Install Hyron CLI

{% code-tabs %} {% code-tabs-item title="YARN" %}

yarn global add @hyron/cli

{% endcode-tabs-item %}

{% code-tabs-item title="NPM" %}

npm i -g @hyron/cli

{% endcode-tabs-item %} {% endcode-tabs %}

Step 2 : Add JSON build file

{% code-tabs %} {% code-tabs-item title="./app.json" %}

{
    "base_url" : "http://localhost:3000",
    "services" : {
        "demo" : "./demo.js"
    }
}

{% endcode-tabs-item %} {% endcode-tabs %}

Step 3 : Add controller file

{% code-tabs %} {% code-tabs-item title="./demo.js" %}

module.exports = class {
    static requestConfig(){
        return {
            sayHello : "get"
        }
    }

    sayHello(name){
        return "hello world !"+name;
    }
}

{% endcode-tabs-item %} {% endcode-tabs %}

Step 4 : Run application

{% code-tabs %} {% code-tabs-item title="Using @hyron/cli" %}

hyron start app.json

{% endcode-tabs-item %}

{% code-tabs-item title="Using hyron" %}

const hyron = require('hyron');

hyron.build("./app.json");

{% endcode-tabs-item %} {% endcode-tabs %}

{% code-tabs %} {% code-tabs-item title="Result" %}

GET http://localhost:3000/demo/say-hello?name=thangphung

{% endcode-tabs-item %} {% endcode-tabs %}