{"id":13411353,"url":"https://github.com/jkyberneees/hydra-integration","last_synced_at":"2025-03-21T07:31:23.633Z","repository":{"id":18872948,"uuid":"85476745","full_name":"jkyberneees/hydra-integration","owner":"jkyberneees","description":"Minimalist 'hydra integration' module, intended for Node.js web frameworks integration.","archived":false,"fork":false,"pushed_at":"2023-01-05T03:53:41.000Z","size":747,"stargazers_count":14,"open_issues_count":17,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T22:42:17.151Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jkyberneees.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-19T13:09:04.000Z","updated_at":"2022-11-21T06:28:30.000Z","dependencies_parsed_at":"2023-01-11T19:59:20.200Z","dependency_job_id":null,"html_url":"https://github.com/jkyberneees/hydra-integration","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkyberneees%2Fhydra-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkyberneees%2Fhydra-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkyberneees%2Fhydra-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkyberneees%2Fhydra-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jkyberneees","download_url":"https://codeload.github.com/jkyberneees/hydra-integration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244757693,"owners_count":20505454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:13.102Z","updated_at":"2025-03-21T07:31:23.350Z","avatar_url":"https://github.com/jkyberneees.png","language":"JavaScript","funding_links":[],"categories":["Web Development"],"sub_categories":["Javascript"],"readme":"# Hydra Integration Module\nIntegrating third-party Node.js web frameworks with Hydra, the simplest way.\n\n\u003e Hydra is a NodeJS package, which facilitates building distributed applications such as Microservices. \n\u003e (https://www.hydramicroservice.com/)\n\nThe magic thing with Hydra is that with a minimum setup, your micro-service get 'superpowers':\n- Distributed Computing\n- Application Clusters + Load Balancer\n- High Availability\n- Centralized Proxy Router\n- Realtime Messaging\n- Service Discovery, Monitoring and Management\n- ... and much more (https://www.hydramicroservice.com/)\n\nBy using this module, you will be able to easily integrate your prefered web framework with hydra. Just keep reading...\n\n## Integrated frameworks\nAt the moment, the following frameworks are supported:\n1. **Express**: Fast, unopinionated, minimalist web framework for Node.js... (http://expressjs.com/)\n2. **Hapi**: A rich framework for building applications and services, hapi enables developers to focus on writing reusable application logic instead of spending time building infrastructure... (https://hapijs.com/)\n3. **Koa**: Koa is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs... (http://koajs.com/)\n4. **Sails.js**: Sails makes it easy to build custom, enterprise-grade Node.js apps... (http://sailsjs.com/)\n5. **Restify**: Restify is a node.js module built specifically to enable you to build correct REST web services... (http://restify.com/)\n6. **Restana**: Super fast and minimalist web framework for building REST micro-services... (https://github.com/jkyberneees/ana)\n7. **Native Hydra Service**: Hydra services are ideal for making distributed API calls through HTTP or real-time events management... (https://www.hydramicroservice.com/)\n\n## Getting Started\nNext we will explain you how to create and express based micro-service on top of hydra:\n\u003e IMPORTANT: Hydra depends on Redis database server for storage, cache and messaging. In case you don't have it yet: https://www.hydramicroservice.com/docs/quick-start/step1.html\n\n1. Install dependencies:\n```bash\nnpm i hydra hydra-integration express --save\n```\n\u003e Express is a dependency here because in the next example we use express, it could be koa or hapi, or any of the supported frameworks.\n\n2. Create and edit app.js file:\n```js\nconst HydraServiceFactory = require('hydra-integration').HydraServiceFactory;\nconst express = require('express');\nconst router = express.Router();\n\nconst factory = new HydraServiceFactory({\n    hydra: {\n        'serviceName': 'express-service-test',\n        'serviceDescription': 'Basic express service on top of Hydra',\n        'serviceIP': '127.0.0.1',\n        'servicePort': 3000,\n        'serviceType': 'express',\n        'serviceVersion': '1.0.0',\n        'redis': {\n            'host': '127.0.0.1',\n            'port': 6379,\n            'db': 15\n        }\n    }\n});\n\nfactory.init().then(factory =\u003e factory.getService(service =\u003e {\n    router.get('/welcome', (req, res) =\u003e res.send('Hello World!'));\n    service.use('/v1', router);\n}));\n```\nAlternative way of getting the service instance by passing config params to the builder (if supported):\n```js\nfactory.init().then(factory =\u003e factory.getService({\n  // optional config params here to be passed to the building strategy\n  bootstrap: service =\u003e {\n    router.get('/welcome', (req, res) =\u003e res.send('Hello World!'));\n    service.use('/v1', router);\n  }\n}));\n```\n\u003e To use hydra-integration as a plugin see: [The HydraIntegrationPlugin class](https://github.com/jkyberneees/hydra-integration/blob/master/docs/HydraIntegrationPlugin.md)\n\n3. Run your service: \n- Single process:\n```bash\nnode app.js\n```\n- Optionally you can run multiple processes with [PM2](http://pm2.keymetrics.io/docs/usage/cluster-mode/):\n```bash\npm2 start app.js -i 4\n```\n4. Test your service using a Web browser at: http://localhost:3000/v1/welcome\n5. Test the service using the hydra-cli (https://www.hydramicroservice.com/docs/tools/hydra-cli/getting-started.html):  \n- List service routes \n```bash\nhydra-cli routes express-service-test\n```\n```json\n{\n  \"serviceName\": [\n    \"[GET]/_health\",\n    \"[GET]/v1/welcome\"\n  ]\n}\n```\n- Invoke the [GET]/v1/welcome service endpoint: \n```bash\nhydra-cli rest express-service-test:[GET]/v1/welcome\n```\n```json\n{\n  \"headers\": {\n    \"x-powered-by\": \"Express\",\n    \"content-type\": \"text/html; charset=utf-8\",\n    \"content-length\": \"12\",\n    \"etag\": \"W/\\\"c-Lve95gjOVATpfV8EL5X4nxwjKHE\\\"\",\n    \"date\": \"Wed, 05 Apr 2017 21:22:51 GMT\",\n    \"connection\": \"close\"\n  },\n  \"body\": \"Hello World!\",\n  \"statusCode\": 200\n}\n```\n\n## Demos\nDemos available into [demos folder](demos) on the git repository: https://github.com/jkyberneees/hydra-integration\n\n## Next Topics \n- [The HydraServiceFactory class](docs/HydraServiceFactory.md)\n- [The HydraIntegrationPlugin class](docs/HydraIntegrationPlugin.md)\n- [Express Framework Integration](docs/ExpressIntegration.md)\n- [Hapi Framework Integration](docs/HapiIntegration.md)\n- [Koa Framework Integration](docs/KoaIntegration.md)\n- [Sails(0.x) Framework Integration](docs/Sails0Integration.md)\n- [Restify Framework Integration](docs/RestifyIntegration.md)\n- [Restana Framework Integration](docs/RestanaIntegration.md)\n- [Native Hydra Integration](docs/NativeIntegration.md)\n- [Creating your own integration](docs/CustomIntegration.md)\n- [Reference documentation](https://www.hydramicroservice.com/)\n\n## Complementary Topics\n- [The Hydra Router](https://github.com/flywheelsports/hydra-router/blob/master/README.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkyberneees%2Fhydra-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjkyberneees%2Fhydra-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkyberneees%2Fhydra-integration/lists"}