Comparing version 0.0.79 to 0.0.80
{ | ||
"name": "webdetta", | ||
"version": "0.0.79", | ||
"version": "0.0.80", | ||
"author": "Fedot Kriutchenko <fodyadev@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "", |
@@ -29,3 +29,3 @@ import { safe } from '../common/func.js'; | ||
const isSecure = ['key', 'cert', 'pfx'].some(k => k in options); | ||
const app = express(); | ||
@@ -35,6 +35,6 @@ const server = (isSecure ? https : http).createServer(options, app); | ||
const wss = WSS({ server }); | ||
const instance = { | ||
server, | ||
launch: (...args) => { | ||
@@ -44,3 +44,3 @@ server.listen(...args); | ||
}, | ||
wsApi: (path, methods) => { | ||
@@ -51,3 +51,3 @@ const api = Api.WS(methods); | ||
}, | ||
httpPostApi: (path, methods) => { | ||
@@ -59,3 +59,3 @@ path = path.replace(/\/$/, '') + '/:name'; | ||
}, | ||
wsHandler: (path, handler) => { | ||
@@ -65,3 +65,3 @@ wss.route(path, handler); | ||
}, | ||
httpHandler: collectMethods((methods=['all'], path, ...args) => { | ||
@@ -71,3 +71,3 @@ for (const method of methods) app[method.toLowerCase()](path, ...args); | ||
}), | ||
wsProxy: (path, resolve) => { | ||
@@ -80,3 +80,3 @@ wss.routeRaw(path, async (req, socket, head) => { | ||
}, | ||
httpProxy: collectMethods((methods=['all'], path, resolve) => { | ||
@@ -90,11 +90,11 @@ for (const method of methods) | ||
}), | ||
sdk: (path, methods) => { | ||
const { serverMethods, clientCode } = SdkServer(methods); | ||
const handler = SdkServer.clientCodeHttpHandler({ isSecure, clientCode }); | ||
instance.httpHandler.get(path, handler); | ||
instance.httpHandler.get(path, cors(), handler); | ||
instance.wsApi(path, serverMethods); | ||
return instance; | ||
}, | ||
static: (path, ...dirs) => { | ||
@@ -104,3 +104,3 @@ for (const dir of dirs) app.use(path, express.static(dir)); | ||
}, | ||
cors: (path, options) => { | ||
@@ -110,3 +110,3 @@ app.options(path, cors(options)); | ||
}, | ||
shutdown: async () => { | ||
@@ -113,0 +113,0 @@ await new Promise(r => server.close(r)); |
94762