{"id":15661270,"url":"https://github.com/sinedied/nano-gateway","last_synced_at":"2025-05-05T21:47:52.329Z","repository":{"id":27818392,"uuid":"115254783","full_name":"sinedied/nano-gateway","owner":"sinedied","description":":zap: Lightweight API gateway for home-scale projects","archived":false,"fork":false,"pushed_at":"2022-12-07T07:56:45.000Z","size":811,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-05T05:49:34.294Z","etag":null,"topics":["api","express","gateway","hacktoberfest","https","nano","secure","yaml"],"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/sinedied.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-24T10:08:21.000Z","updated_at":"2023-10-20T09:50:56.000Z","dependencies_parsed_at":"2023-01-14T07:33:16.267Z","dependency_job_id":null,"html_url":"https://github.com/sinedied/nano-gateway","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinedied%2Fnano-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinedied%2Fnano-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinedied%2Fnano-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinedied%2Fnano-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinedied","download_url":"https://codeload.github.com/sinedied/nano-gateway/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252582667,"owners_count":21771702,"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":["api","express","gateway","hacktoberfest","https","nano","secure","yaml"],"created_at":"2024-10-03T13:26:46.068Z","updated_at":"2025-05-05T21:47:52.308Z","avatar_url":"https://github.com/sinedied.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nano-gateway\n\n[![NPM version](https://img.shields.io/npm/v/nano-gateway.svg)](https://www.npmjs.com/package/nano-gateway)\n[![Build status](https://github.com/sinedied/nano-gateway/workflows/build/badge.svg)](https://github.com/sinedied/nano-gateway/actions)\n![Node version](https://img.shields.io/badge/node-%3E%3D14.0.0-brightgreen.svg)\n[![Docker Hub](https://img.shields.io/docker/image-size/sinedied/nano-gateway?sort=semver)](https://hub.docker.com/r/sinedied/nano-gateway/)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n![](https://user-images.githubusercontent.com/593151/34394053-379cfa3c-eb57-11e7-855d-ef15cc5d3bcb.png)\n\n\u003e Lightweight API gateway for home-scale projects.\n\n**Features:**\n- Single-file YAML configuration\n- HTTPS support\n- Secure endpoints with API key\n- URL rewriting\n- Less than [60 LOC](index.js) :smile:\n\n## Installation\n\n```bash\nnpm install -g nano-gateway\n```\n\n## Usage\n```sh\nUsage: nanog [--config file.yml] [--keygen]\n```\n\nUse the `nanog` command to start the gateway.\n\nBy default, it will use the `config.yml` configuration in the current working directory, but any file can be specified\nusing either the `NANO_GATEWAY_CONFIG` environment variable or the `--config` option.\n\nThe `--keygen` will generate a suitable API key to use in your configuration.\n\n## Configuration\n\nHere is an [example config.yml](config.yml) configuration:\n\n```yaml\nhttp:                 # optional, enable HTTP gateway\n  port: 8080          # optional, specify port for HTTP (default is 8080)\nhttps:                # optional, enable HTTPS gateway\n  cert: 'cert.pem'    # required, certificate path\n  key: 'privkey.pem'  # required, private key path\n  ca: 'chain.pem'     # optional, override trusted CA certificates\n  port: 8443          # optional, specify port for HTTPS (default is 8443)\nauth: true            # optional, enable API key authorization by default for all services\napiKey: '123456'      # required if auth is enabled, use nanog --keygen to generate a new key\nservices:             # required, define here the services to proxify\n  ip:                           # required, service name\n    path: '/ip'                 # required, endpoint(s) (use Express route syntax, see npmjs.com/path-to-regexp)\n    url: 'https://httpbin.org'  # required, target url for\n    auth: false                 # optional, authorization can be set or overriden by service\n  quote:                        # another service, add as many as you need\n    path: '/jokes/*'            # matches any routes under /jokes/\n    rewrite: '/jokes/random'    # optional, rewrite URL (for syntax, see npmjs.com/express-urlrewrite)\n    url: 'https://api.chucknorris.io'\n```\n\n### API key\n\nEndpoints secured by API key can be consumed either by using an `apiKey` query parameter:\n```sh\ncurl https://gateway.com/endpoint?apiKey=\u003cyour_api_key\u003e\n```\nor by using an `Authorization` header:\n```sh\ncurl -H \"Authorization: \u003cyour_api_key\u003e\" https://gateway.com/endpoint\n```\n\n\u003e Note: It is **strongly** recommended to use only HTTPS with API keys, otherwise your credentials will circulate in\n\u003e clear over the network and may be intercepted.\n\n### HTTPS\n\nTo enable HTTPS you need a valid SSL certificate.\n\nFree [LetsEncrypt](https://letsencrypt.org) certificates can be obtained using [certbot](https://certbot.eff.org).\n\nFor testing purposes, you can also generate a self-signed certificate using this command:\n```sh\nopenssl req -nodes -new -x509 -keyout privkey.pem -out cert.pem\n```\n\nAfter you have your certificate, use it in your configuration like this:\n```yaml\nhttps:\n  cert: 'cert.pem'\n  key: 'privkey.pem'\n  ca: 'chain.pem' # optional, override trusted CA certificates\n```\n\n## Running on Docker\n\nA minimal [Docker image](https://hub.docker.com/r/sinedied/nano-gateway/) based on `node:alpine` is also available\nfor deployment.\n\nYou just need to map a folder with a `config.yml` file in it to the `/config` volume:\n```\ndocker pull sinedied/nano-gateway\ndocker run --d -v \u003cyour_config_dir\u003e:/config -p 8443:8443 --name nano-gateway sinedied/nano-gateway\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinedied%2Fnano-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinedied%2Fnano-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinedied%2Fnano-gateway/lists"}