Comparing version 0.0.60 to 0.0.61
{ | ||
"name": "webdetta", | ||
"version": "0.0.60", | ||
"version": "0.0.61", | ||
"author": "Fedot Kriutchenko <fodyadev@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "", |
import { safe } from '../common/func.js'; | ||
import { Api } from '../sdk/api.js'; | ||
import { SdkServer } from '../sdk/index.js'; | ||
import { Api } from '../sdk/common.js'; | ||
import { SdkServer } from '../sdk/server.js'; | ||
import bytes from 'bytes'; | ||
@@ -9,2 +9,3 @@ import express from 'express'; | ||
import http from 'http'; | ||
import https from 'https'; | ||
import httpProxy from 'http-proxy'; | ||
@@ -27,6 +28,7 @@ import WSS from './wss.js'; | ||
const Server = () => { | ||
let isSecure = false; | ||
const Server = (options={}) => { | ||
const isSecure = ['key', 'cert', 'pfx'].some(k => k in options); | ||
const app = express(); | ||
const server = http.createServer(app); | ||
const server = (isSecure ? https : http).createServer(options, app); | ||
const proxy = httpProxy.createProxyServer({ ws: true }); | ||
@@ -49,3 +51,3 @@ const wss = WSS({ server }); | ||
httpApi: (path, methods) => { | ||
httpPostApi: (path, methods) => { | ||
path = path.replace(/\/$/, '') + '/:name'; | ||
@@ -86,3 +88,3 @@ const api = Api.HTTP(methods); | ||
const { serverMethods, clientCode } = SdkServer(methods); | ||
const handler = SdkServer.httpHandler({ isSecure, clientCode }) | ||
const handler = SdkServer.clientCodeGetHandler({ isSecure, clientCode }); | ||
instance.httpHandler.get(path, handler); | ||
@@ -89,0 +91,0 @@ instance.wsApi(path, serverMethods); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
31386
29
923
6