{"id":28205685,"url":"https://github.com/hodonsky/node-gateway","last_synced_at":"2026-02-25T18:37:41.449Z","repository":{"id":276844691,"uuid":"280784204","full_name":"hodonsky/node-gateway","owner":"hodonsky","description":"Gateway message to MQ topic with action for SOA based on AMQP 0-9-1","archived":false,"fork":false,"pushed_at":"2025-04-09T13:30:15.000Z","size":708,"stargazers_count":1,"open_issues_count":16,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-26T21:04:34.604Z","etag":null,"topics":["amqp","node-gateway","nodejs","soa"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hodonsky.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-07-19T03:29:21.000Z","updated_at":"2025-03-22T22:43:13.000Z","dependencies_parsed_at":"2025-05-17T10:08:23.330Z","dependency_job_id":"03f720ec-44a8-4cea-a6f9-c6a924caedd9","html_url":"https://github.com/hodonsky/node-gateway","commit_stats":null,"previous_names":["hodonsky/node-gateway"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/hodonsky/node-gateway","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hodonsky%2Fnode-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hodonsky%2Fnode-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hodonsky%2Fnode-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hodonsky%2Fnode-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hodonsky","download_url":"https://codeload.github.com/hodonsky/node-gateway/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hodonsky%2Fnode-gateway/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29834631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T17:57:15.019Z","status":"ssl_error","status_checked_at":"2026-02-25T17:56:11.472Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["amqp","node-gateway","nodejs","soa"],"created_at":"2025-05-17T10:08:19.711Z","updated_at":"2026-02-25T18:37:41.443Z","avatar_url":"https://github.com/hodonsky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node-Gateway\n\nThis is the gateway side of the SOA.\n\n### Prerequisites ( standard AMQP 0-9-1 ):\n- AMQP Server/Cluster accepting connections with credentials. ( see  [`Local`](#Local) setup )\n- Consumer Service(s)/Cluster(s) responding on responseTopic with CorrelationID. ([@donsky/node-service](https://www.npmjs.com/package/@donsky/node-service) )\n\n\n### Impliments:\n- NodeJS\n- AVRO Message Standards \u0026 Schema ( dependancy: avsc )\n- AMQP 0-9-1 Communication Standard ( dependancy: amqplib )\n- Babel 7 \u0026 ESNext plugins ( dependancy: babel-* )\n- KoaJS net server listening on `PORT` ( dependancy: koa \u0026 koa-* )\n\n## Initialize Your Gateway Server\n\n```javascript\n// -- CommonJS --\nconst Gateway = require( \"@donsky/node-gateway\" ).default\n\n// -- ESNext --\nimport Gateway from \"@donsky/node-gateway\"\n\n\nnew Gateway(/*[action1[,action2]]*/)\n```\n\n## Configure\nAll of the following configurations must be handled in the env vars, or in config in the code. Examples below:\n\n### ENV VARS\n\nAdd the following to your bashrc, or bash profile depending on environment.\nI use docker-compose so I just attach them to the container environment.\nThese will be picked up automatically by the default config file.\n\n```bash\nexport PORT=80\nexport MQ_PROTOCOL=amqp\nexport MQ_HOSTNAME=rabbitmq\nexport MQ_PORT=5672\nexport MQ_USERNAME=admin\nexport MQ_PASSWORD=Abcd1234\nexport MQ_QUEUE=gateway\n```\n###### The hostname can be a URI or a local hostname, in this example, _'rabbitmq'_ is my docker container hostname. During deploy this would change and be environment specific.\n\n### Code\n```javascript\nGateway.configure({\n  mq:{\n    username: \"admin\",\n    password: \"Abcd1234\"\n    hostname: \"rabbitmq\"\n    port    : 5672\n  },\n  port: 80\n})\n```\n\n\n## Action Object Options:\n\n```javascript\n// action.js\n\n/** \n * Required Attributes\n */\nconst required = {\n  topic       : \"consumerTopic\",\n  method      : \"get\"|\"post\"|\"put\"|\"put\"|\"update\"|\"delete\",\n  route       : \"/route-path\",\n  name        : \"consumerActionName\",\n  requestAVRO : [\n    { name: \"firstName\", type: \"string\" }\n  ],\n  responseAVRO: [\n    { name: \"response\", type: \"string\" }\n  ],\n  errorAVRO:[\n    { name: \"error\", type: \"string\" }\n  ]\n}\n\u003e I share a file with my service\n\n/**\n * Optional Attributes\n */\nconst optional = {\n  /**\n   * Defaults to (ctx)=\u003ectx\n   * One transformer is fine this is\n   * just an example of chaining.\n   */\n  requestTransformers : [\n    ( ctx ) =\u003e ctx.request.body.firstName,\n    ( firstName )=\u003e requestAVRO\n  ],\n  /**\n   * Defaults to (responseAVRO)=\u003eresponseAVRO\n   * One transformer is fine this is\n   * just an example of chaining.\n   */\n  responseTransformers: [ // Optional\n    ( responseAVRO ) =\u003e ( responseAVRO.response ),\n    ( response ) =\u003e ( { lastName: response } )\n  ]\n}\n\n// -- CommonJS --\nmodule.exports = Object.assign( {}, required, optional )\n// -- ESNext --\nexport default { ...required, ...optional }\n```\n\n#### Example:\n\n```javascript\n// -- CommonJS --\nconst action = require( \"./action\" )\n// -- ESNext --\nimport action from \"./action\"\n\nGateway.configure({port:80})\nnew Gateway([action])\n```\n\n\u003cbr/\u003e\n\n\u003e Notes:\n\u003e - Without any __actions__ the server should start, but it won't do much\n\u003e - Port __80__ is not allowed to be exposed on a mac, so the default is actually 8080: This can be found in __(./lib/config.js).port__\n\u003e - This works well with PM2 (Process Manager 2)\n\u003cbr/\u003e\n\n## Local:\n\nMay I recommend spinning up a docker environment for those prerequisites, and getting all the services talking:\n```Dockerfile\n# Note: I use a docker container\nversion: \"3.8\"\nservices:\n  rabbitmq:\n    image: rabbitmq:management\n    ports:\n     - \"5672:5672\"\n     - \"15672:15672\"\n    environment:\n      # ${ENV_VAR} work here for values as well\n      RABBITMQ_DEFAULT_USER: defaultAdmin\n      RABBITMQ_DEFAULT_PASS: SomePassword\n    restart: on-failure   \n  gateway:\n    build:\n      context: ./\n    ports:\n     - \"80:80\"\n    environment:\n     - NODE_ENV=local\n     - HOSTNAME=gateway\n     - PORT=80\n     - MQ_PROTOCOL=amqp\n     - MQ_HOSTNAME=rabbitmq\n     - MQ_PORT=5672\n     - MQ_USERNAME=defaultAdmin\n     - MQ_PASSWORD=SomePassword\n    depends_on:\n     - rabbitmq\n    restart: on-failure\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhodonsky%2Fnode-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhodonsky%2Fnode-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhodonsky%2Fnode-gateway/lists"}