description |
---|
This article discusses the basic steps to building a simple hello-world project with a hyron |
{% hint style="info" %} you can clone & run this example on github : https://github.com/thangdjw/hyron-helloworld {% endhint %}
{% 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 %}
{% code-tabs %} {% code-tabs-item title="./app.json" %}
{
"base_url" : "http://localhost:3000",
"services" : {
"demo" : "./demo.js"
}
}
{% endcode-tabs-item %} {% endcode-tabs %}
{% 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 %}
{% 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 %}