{"id":21893330,"url":"https://github.com/norjs/portal-service","last_synced_at":"2025-03-22T03:44:14.541Z","repository":{"id":51754530,"uuid":"185055306","full_name":"norjs/portal-service","owner":"norjs","description":"HTTP Gateway Service.","archived":false,"fork":false,"pushed_at":"2022-12-30T18:12:07.000Z","size":141,"stargazers_count":0,"open_issues_count":16,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T14:50:13.250Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.norjs.com","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/norjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-05-05T16:23:17.000Z","updated_at":"2019-11-24T16:56:13.000Z","dependencies_parsed_at":"2023-01-31T12:46:09.441Z","dependency_job_id":null,"html_url":"https://github.com/norjs/portal-service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norjs%2Fportal-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norjs%2Fportal-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norjs%2Fportal-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norjs%2Fportal-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/norjs","download_url":"https://codeload.github.com/norjs/portal-service/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244902921,"owners_count":20529114,"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-11-28T13:13:28.067Z","updated_at":"2025-03-22T03:44:14.522Z","avatar_url":"https://github.com/norjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @norjs/portal-service\n\nThis is a micro service acting as a HTTP gateway between services.\n\nSee also [@norjs/manager-service](https://github.com/norjs/manager-service) which can use the same configuration file and manages service start \u0026 stop.\n\nThe main use case is to act as an authorizing gateway between TCP/IP network and local file-based socket services.\n\n### Configuration File\n\nA configuration file `./nor.json` could look like:\n\n```json\n{\n  \"auth\": {\n    \"default\": {\n      \"path\": \"./MyAuthenticator.js\",\n      \"config\": \"./auth.json\"\n    }\n  },\n  \"routes\": {\n    \"/event\": {\n      \"socket\": \"./event.sock\",\n      \"auth\": \"default\"\n    },\n    \"/database\": {\n      \"socket\": \"./database.sock\",\n      \"auth\": \"default\"\n    },\n    \"/public\": {\n      \"target\": \"http://public.example.com/\"\n    }\n  }\n}\n```\n\n### Authentication\n\nImplement an authenticator in a file named `./MyAuthenticator.js`:\n\n```js\n/**\n * @implements {NorPortalAuthenticator}\n */\nclass MyAuthenticator {\n    \n    constructor (config) {\n        this._config = config;\n    }\n    \n    /**\n     * \n     * @param context {NorPortalContextObject}\n     * @returns {boolean}\n     */\n    hasAccess (context) {\n        return !!context \u0026\u0026 (context.password === this._config.password);\n    }\n    \n}\n\nmodule.exports = MyAuthenticator;\n```\n\n***Note!*** This is just a simplified example.\n\n### Start the service\n\nStart in a TCP port `localhost:3000`:\n\n```\nNODE_LISTEN='3000' nor-portal-service\n```\n\nStart in a socket file:\n\n```\nNODE_LISTEN='./portal.sock' nor-portal-service\n```\n\nThe configuration will be readed from `./nor.json` by default. You may change it:\n\n```\nNOR_PORTAL_CONFIG='./portal/nor.json' \\\nNODE_LISTEN='./portal.sock' \\\nnor-portal-service\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorjs%2Fportal-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnorjs%2Fportal-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorjs%2Fportal-service/lists"}