{"id":13630441,"url":"https://github.com/dimapaloskin/dev-gateway","last_synced_at":"2025-04-13T13:16:10.376Z","repository":{"id":83057102,"uuid":"87322921","full_name":"dimapaloskin/dev-gateway","owner":"dimapaloskin","description":"Local development cluster with \"now\" path aliases syntax support. Allows running multiple microservices as one solid server.","archived":false,"fork":false,"pushed_at":"2020-06-03T09:20:10.000Z","size":4250,"stargazers_count":32,"open_issues_count":14,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T13:16:02.939Z","etag":null,"topics":["cluster","gateway","http","javascript","js","micro","microservices","now","server"],"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/dimapaloskin.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-05T15:00:36.000Z","updated_at":"2019-11-13T06:26:39.000Z","dependencies_parsed_at":"2024-01-06T00:04:59.234Z","dependency_job_id":null,"html_url":"https://github.com/dimapaloskin/dev-gateway","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimapaloskin%2Fdev-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimapaloskin%2Fdev-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimapaloskin%2Fdev-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimapaloskin%2Fdev-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimapaloskin","download_url":"https://codeload.github.com/dimapaloskin/dev-gateway/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717237,"owners_count":21150389,"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":["cluster","gateway","http","javascript","js","micro","microservices","now","server"],"created_at":"2024-08-01T22:01:42.953Z","updated_at":"2025-04-13T13:16:10.349Z","avatar_url":"https://github.com/dimapaloskin.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Development Tools"],"sub_categories":["Utilities"],"readme":"# dev-gateway\n\n\u003e Local development cluster with [now path aliases](https://zeit.co/docs/features/path-aliases) syntax support. Allows running multiple microservices as one solid server.\n\n[![Build Status](https://travis-ci.org/dimapaloskin/dev-gateway.svg?branch=master)](https://travis-ci.org/dimapaloskin/dev-gateway)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n[![Greenkeeper badge](https://badges.greenkeeper.io/dimapaloskin/dev-gateway.svg)](https://greenkeeper.io/)\n\n## Installation\n```shell\nnpm install --save-dev dev-gateway\n# or\nyarn add -D dev-gateway\n```\n\n## Usage\n\nAt first, you need to create `app.js` file and define configuration:\n\n```js\nmodule.exports = {\n  port: 3000,\n  host: 'localhost',\n  rules: [{\n    slug: 'auth',\n    pathname: '/api/auth/**',\n    dest: 'auth.api.localhost',\n    run: 'micro index.js',\n    cwd: './auth',\n    env: {\n      SECRET_TOKEN: 'kittens'\n    },\n    debug: true\n  }, {\n    slug: 'accounts',\n    pathname: '/api/accounts',\n    dest: 'accounts.api.localhost',\n    method: ['GET', 'POST'],\n    run: 'cd ./accounts \u0026\u0026 micro index.js',\n    debug: true\n  }, {\n    pathname: '/api/entries/*',\n    dest: 'entries.api.localhost',\n    run: 'cd ./entries \u0026\u0026 micro index.js',\n    debug: true\n  }, {\n    pathname: '/proxy',\n    dest: 'proxy.api.localhost',\n    proxy: 'https://first.pong.world/any/path'\n  }]\n}\n```\n\nThe next step is to add a new script to your `package.json`:\n```json\n{\n  \"scripts\": {\n    \"dev\": \"dev-gateway serve app.js\"\n  }\n}\n```\n\nThen run:\n```sh\nnpm run dev\n```\n\n## Rules\n\nRules access the following parametres:\n- **slug** - slug, just a name of rule\n- **pathname** - pathname alias; has similar wildcard syntax to this one [now path aliases](https://zeit.co/docs/features/path-aliases)\n- **dest** - destination host. Microservice will be available if you send request directly to the host.\n- **method** - string or array. To specify allowed methods.\n- **run** - shell command to run your microservice.\n- **port** - port used by microservice. Gateway will try to detect opened port if these parametres are not defined.\n- **proxy** - url. All requests will be proxied to this url if parameter is defined.\n- **debug** - boolean or object (`{ stdout: false, stderr: true}`). Gateway will pipe microservice output to the terminal, if 'debug' is true.\n- **env** - the parameter is used to define environment variables for a microservice.\n- **logFile** - will pipe stdout and stderr to a specified file.\n- **cwd** - rule's working directory\n- **maxGetPortAttempts** - number of attempts to obtain a rule's port. Each attempt waits for 1 second. E.g. set\n`maxGetPortAttempts` to 30 to wait for 30 seconds before a rule is marked as \"not available\". Defaults to 10.\n- **startTimeout** - timeout (in ms) before start port checking (useful for long starting apps)\n\n## Cli\n\n**Run:**\n\n```shell\ndev-gateway serve app.js -p 3000 -h localhost\n```\n\n- `-p, --port` - port\n- `-h, --host` - host\n- `-S, --skip` - skip whole rule by slug\n- `-s, --skip-run` - skip running stage by slug (it can be useful if you want to run microservice manually, but you still needed requests proxying)\n\n**Extract:**\n\n```shell\ndev-gateway extract app.js --dest example.com --output rules.json\n```\n\nWill extract current configuration to `rules.json` file\n\n- `-d, --dest` - destination\n- `-o, --output` - output file with rules\n\n## In action\nClone this repo and run:\n\n```shell\nnpm install\nnpm run example\n```\n\nYou can check test server in the `test/example` directory.\n\n## Alternatives\n\n- [serve-micro-cluster](https://github.com/tylersnyder/serve-micro-cluster) - Easily start a local cluster of [micro](https://github.com/zeit/micro)-based services using a simple rules.json file. It's like Path Alias on [now](https://zeit.co/now), but for local development.\n- [micro-cluster](https://github.com/zeit/micro-cluster) - Run multiple micro servers and a front proxy at a time, with a simple configuration file.\n\n### Author\n[Dmitry Pavlovsky](http://palosk.in)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimapaloskin%2Fdev-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimapaloskin%2Fdev-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimapaloskin%2Fdev-gateway/lists"}