Hydra Generator
The Hydra Generator is a command line tool that allows you to quickly build the complete scaffolding for a Hydra or Hydra-Express application. The generator relies on a tool called Yeoman.
The great thing about the generator is that you can build a microservice in just under 15 seconds. You can then proceed to customize the generated code to suit your particular needs.
Getting started
First install Yeoman and the generator globally.
$ sudo npm install -g yo generator-fwsp-hydra
To use the generator you simply invoke yeoman with the name of the generator. In our case the hydra-generator is named fwsp-hydra. The first prompt you get asks you to name your service.
$ yo fwsp-hydra
? Name of the service (`-service` will be appended automatically) hello
After a number of other questions (for which you can select default) the process ends with instructions on how to build and start your new project.
Done!
'cd example-service' then 'npm install' and 'npm start'
Keep in mind that Hydra services require the use of a Redis instance. So before you can run your app you need to have redis available. By default the Hydra Generator will create a config file which expects a local instance of Redis.
{
"environment": "development",
"hydra": {
"serviceName": "hello-service",
"serviceIP": "",
"servicePort": 5000,
"serviceType": "hello",
"serviceDescription": "says hello",
"redis": {
"url": "redis://127.0.0.1:6379/15"
}
}
}