@interopio/gateway-server
v0.19.3
Published
[](https://www.npmjs.com/package/@interopio/gateway-server)
Readme
io.Gateway Server
Overview
The @interopio/gateway-server package is the web server used to run the gateway as a standalone server app accessible via WebSocket.
Table of Contents
Getting Started
import GatewayServer, {type Server} from '@interopio/gateway-server';
const server: Server = await GatewayServer({
port: 8385,
gateway: {
route: '/gw',
access: 'authenticated',
ping: {
interval: 30000, // 30 seconds
type: 'timestamp'
}
}
});
await server.close();Configure HTTPS
import GatewayServer, {type Server} from '@interopio/gateway-server';
const server: Server = await GatewayServer({
port: 8443,
ssl: {
cert: "glue42.crt",
ca: "intermediate.crt",
key: "glue42.key"
},
auth: {
type: 'oauth2', // or 'basic'
oauth2: {
jwt: {
issuer: 'https://auth.example.com',
audience: 'https://api.example.com'
}
},
basic: {
username: 'interopio',
password: 'passwordo'
}
},
app: async ({handle}) => {
handle(
{
request: {method: 'GET', path: '/api/metrics'},
options: {cors: true, authorize: {access: 'authenticated'}},
handler: async ({response}) => {
response.setStatusCode({value: 200}); // OK
await response.end();
}
},
{
request: {method: 'POST', path: '/api/metrics'},
options: {cors: true, authorize: {access: 'authenticated'}},
handler: async ({request, response}) => {
response.statusCode({value: 202}); // Accepted
await response.end();
try {
const update = await request.json();
console.log(`${JSON.stringify(update)}`);
} catch (e) {
console.error('Error processing metrics:', e);
}
}
});
},
});
await server.close();
@glue42/gateway-ent Compatibility
This package aims to provide compatibility with @glue42/gateway-ent proprietary package used in Glue42 Desktop (now io.Connect Desktop)
import * as gw from '@interopio/gateway-server/gateway-ent';Changelog
See changelog
