Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/norjs/portal-service
HTTP Gateway Service.
https://github.com/norjs/portal-service
Last synced: 25 days ago
JSON representation
HTTP Gateway Service.
- Host: GitHub
- URL: https://github.com/norjs/portal-service
- Owner: norjs
- License: mit
- Created: 2019-05-05T16:23:17.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T18:12:07.000Z (almost 2 years ago)
- Last Synced: 2024-11-13T21:11:48.937Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://www.norjs.com
- Size: 138 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @norjs/portal-service
This is a micro service acting as a HTTP gateway between services.
See also [@norjs/manager-service](https://github.com/norjs/manager-service) which can use the same configuration file and manages service start & stop.
The main use case is to act as an authorizing gateway between TCP/IP network and local file-based socket services.
### Configuration File
A configuration file `./nor.json` could look like:
```json
{
"auth": {
"default": {
"path": "./MyAuthenticator.js",
"config": "./auth.json"
}
},
"routes": {
"/event": {
"socket": "./event.sock",
"auth": "default"
},
"/database": {
"socket": "./database.sock",
"auth": "default"
},
"/public": {
"target": "http://public.example.com/"
}
}
}
```### Authentication
Implement an authenticator in a file named `./MyAuthenticator.js`:
```js
/**
* @implements {NorPortalAuthenticator}
*/
class MyAuthenticator {
constructor (config) {
this._config = config;
}
/**
*
* @param context {NorPortalContextObject}
* @returns {boolean}
*/
hasAccess (context) {
return !!context && (context.password === this._config.password);
}
}module.exports = MyAuthenticator;
```***Note!*** This is just a simplified example.
### Start the service
Start in a TCP port `localhost:3000`:
```
NODE_LISTEN='3000' nor-portal-service
```Start in a socket file:
```
NODE_LISTEN='./portal.sock' nor-portal-service
```The configuration will be readed from `./nor.json` by default. You may change it:
```
NOR_PORTAL_CONFIG='./portal/nor.json' \
NODE_LISTEN='./portal.sock' \
nor-portal-service
```