@based/server 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BasedServerClient.d.ts +71 -0
- package/dist/BasedServerClient.js +390 -0
- package/dist/BasedServerClient.js.map +1 -0
- package/dist/Client.d.ts +75 -0
- package/dist/Client.js +277 -0
- package/dist/Client.js.map +1 -0
- package/dist/Params.d.ts +20 -0
- package/dist/Params.js +48 -0
- package/dist/Params.js.map +1 -0
- package/dist/auth/authorize.d.ts +2 -0
- package/dist/auth/authorize.js +8 -0
- package/dist/auth/authorize.js.map +1 -0
- package/dist/clientContext.d.ts +0 -0
- package/dist/clientContext.js +83 -0
- package/dist/clientContext.js.map +1 -0
- package/dist/closeListener.d.ts +4 -0
- package/dist/closeListener.js +13 -0
- package/dist/closeListener.js.map +1 -0
- package/dist/createSimpleServer.d.ts +22 -0
- package/dist/createSimpleServer.js +120 -0
- package/dist/createSimpleServer.js.map +1 -0
- package/dist/error.d.ts +66 -0
- package/dist/error.js +149 -0
- package/dist/error.js.map +1 -0
- package/dist/findPrefix.d.ts +3 -0
- package/dist/findPrefix.js +20 -0
- package/dist/findPrefix.js.map +1 -0
- package/dist/functions/types.d.ts +0 -2
- package/dist/functions/types.js.map +1 -1
- package/dist/functions/workerPool.d.ts +0 -0
- package/dist/functions/workerPool.js +5 -0
- package/dist/functions/workerPool.js.map +1 -0
- package/dist/getFromConfig.d.ts +3 -0
- package/dist/getFromConfig.js +50 -0
- package/dist/getFromConfig.js.map +1 -0
- package/dist/handlers/authorize.d.ts +5 -0
- package/dist/handlers/authorize.js +196 -0
- package/dist/handlers/authorize.js.map +1 -0
- package/dist/handlers/bulkUpdate/index.d.ts +5 -0
- package/dist/handlers/bulkUpdate/index.js +26 -0
- package/dist/handlers/bulkUpdate/index.js.map +1 -0
- package/dist/handlers/configuration/index.d.ts +10 -0
- package/dist/handlers/configuration/index.js +74 -0
- package/dist/handlers/configuration/index.js.map +1 -0
- package/dist/handlers/configuration/observable/index.d.ts +46 -0
- package/dist/handlers/configuration/observable/index.js +277 -0
- package/dist/handlers/configuration/observable/index.js.map +1 -0
- package/dist/handlers/configure/index.d.ts +5 -0
- package/dist/handlers/configure/index.js +44 -0
- package/dist/handlers/configure/index.js.map +1 -0
- package/dist/handlers/copy/index.d.ts +8 -0
- package/dist/handlers/copy/index.js +135 -0
- package/dist/handlers/copy/index.js.map +1 -0
- package/dist/handlers/delete/index.d.ts +5 -0
- package/dist/handlers/delete/index.js +34 -0
- package/dist/handlers/delete/index.js.map +1 -0
- package/dist/handlers/digest/index.d.ts +5 -0
- package/dist/handlers/digest/index.js +23 -0
- package/dist/handlers/digest/index.js.map +1 -0
- package/dist/handlers/functions/call.d.ts +6 -0
- package/dist/handlers/functions/call.js +54 -0
- package/dist/handlers/functions/call.js.map +1 -0
- package/dist/handlers/functions/observable/Observable.d.ts +49 -0
- package/dist/handlers/functions/observable/Observable.js +290 -0
- package/dist/handlers/functions/observable/Observable.js.map +1 -0
- package/dist/handlers/functions/observable/SharedObservable.d.ts +45 -0
- package/dist/handlers/functions/observable/SharedObservable.js +291 -0
- package/dist/handlers/functions/observable/SharedObservable.js.map +1 -0
- package/dist/handlers/functions/observable/index.d.ts +14 -0
- package/dist/handlers/functions/observable/index.js +130 -0
- package/dist/handlers/functions/observable/index.js.map +1 -0
- package/dist/handlers/get/index.d.ts +5 -0
- package/dist/handlers/get/index.js +23 -0
- package/dist/handlers/get/index.js.map +1 -0
- package/dist/handlers/getConfig/index.d.ts +5 -0
- package/dist/handlers/getConfig/index.js +38 -0
- package/dist/handlers/getConfig/index.js.map +1 -0
- package/dist/handlers/handleRequests.d.ts +5 -0
- package/dist/handlers/handleRequests.js +78 -0
- package/dist/handlers/handleRequests.js.map +1 -0
- package/dist/handlers/index.d.ts +4 -0
- package/dist/handlers/index.js +49 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/messageParser.d.ts +5 -0
- package/dist/handlers/messageParser.js +122 -0
- package/dist/handlers/messageParser.js.map +1 -0
- package/dist/handlers/removeField/index.d.ts +5 -0
- package/dist/handlers/removeField/index.js +42 -0
- package/dist/handlers/removeField/index.js.map +1 -0
- package/dist/handlers/removeType/index.d.ts +5 -0
- package/dist/handlers/removeType/index.js +30 -0
- package/dist/handlers/removeType/index.js.map +1 -0
- package/dist/handlers/rest/file/DataStream.d.ts +7 -0
- package/dist/handlers/rest/file/DataStream.js +17 -0
- package/dist/handlers/rest/file/DataStream.js.map +1 -0
- package/dist/handlers/rest/file/formStream.d.ts +4 -0
- package/dist/handlers/rest/file/formStream.js +188 -0
- package/dist/handlers/rest/file/formStream.js.map +1 -0
- package/dist/handlers/rest/file/getExtenstion.d.ts +2 -0
- package/dist/handlers/rest/file/getExtenstion.js +22 -0
- package/dist/handlers/rest/file/getExtenstion.js.map +1 -0
- package/dist/handlers/rest/file/index.d.ts +4 -0
- package/dist/handlers/rest/file/index.js +53 -0
- package/dist/handlers/rest/file/index.js.map +1 -0
- package/dist/handlers/rest/file/storeFile.d.ts +6 -0
- package/dist/handlers/rest/file/storeFile.js +44 -0
- package/dist/handlers/rest/file/storeFile.js.map +1 -0
- package/dist/handlers/rest/file/stream.d.ts +5 -0
- package/dist/handlers/rest/file/stream.js +104 -0
- package/dist/handlers/rest/file/stream.js.map +1 -0
- package/dist/handlers/rest/file/types.d.ts +9 -0
- package/dist/handlers/rest/file/types.js +3 -0
- package/dist/handlers/rest/file/types.js.map +1 -0
- package/dist/handlers/rest/getReqMessage.d.ts +3 -0
- package/dist/handlers/rest/getReqMessage.js +92 -0
- package/dist/handlers/rest/getReqMessage.js.map +1 -0
- package/dist/handlers/rest/index.d.ts +4 -0
- package/dist/handlers/rest/index.js +121 -0
- package/dist/handlers/rest/index.js.map +1 -0
- package/dist/handlers/rest/invalidReq.d.ts +4 -0
- package/dist/handlers/rest/invalidReq.js +20 -0
- package/dist/handlers/rest/invalidReq.js.map +1 -0
- package/dist/handlers/rest/parseResponse.d.ts +6 -0
- package/dist/handlers/rest/parseResponse.js +230 -0
- package/dist/handlers/rest/parseResponse.js.map +1 -0
- package/dist/handlers/rest/playground/index.d.ts +5 -0
- package/dist/handlers/rest/playground/index.js +308 -0
- package/dist/handlers/rest/playground/index.js.map +1 -0
- package/dist/handlers/rest/readBody.d.ts +3 -0
- package/dist/handlers/rest/readBody.js +45 -0
- package/dist/handlers/rest/readBody.js.map +1 -0
- package/dist/handlers/set/index.d.ts +5 -0
- package/dist/handlers/set/index.js +20 -0
- package/dist/handlers/set/index.js.map +1 -0
- package/dist/handlers/subscription/index.d.ts +32 -0
- package/dist/handlers/subscription/index.js +223 -0
- package/dist/handlers/subscription/index.js.map +1 -0
- package/dist/handlers/token.d.ts +5 -0
- package/dist/handlers/token.js +122 -0
- package/dist/handlers/token.js.map +1 -0
- package/dist/handlers/track/index.d.ts +7 -0
- package/dist/handlers/track/index.js +102 -0
- package/dist/handlers/track/index.js.map +1 -0
- package/dist/handlers/userAuth/index.d.ts +5 -0
- package/dist/handlers/userAuth/index.js +78 -0
- package/dist/handlers/userAuth/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/network/http/authorize.d.ts +3 -0
- package/dist/network/http/authorize.js +28 -0
- package/dist/network/http/authorize.js.map +1 -0
- package/dist/network/http/compress.d.ts +6 -0
- package/dist/network/http/compress.js +56 -0
- package/dist/network/http/compress.js.map +1 -0
- package/dist/network/http/end.d.ts +4 -0
- package/dist/network/http/end.js +19 -0
- package/dist/network/http/end.js.map +1 -0
- package/dist/network/http/function.d.ts +3 -0
- package/dist/network/http/function.js +47 -0
- package/dist/network/http/function.js.map +1 -0
- package/dist/network/http/get.d.ts +3 -0
- package/dist/network/http/get.js +129 -0
- package/dist/network/http/get.js.map +1 -0
- package/dist/network/http/index.d.ts +3 -0
- package/dist/network/http/index.js +122 -0
- package/dist/network/http/index.js.map +1 -0
- package/dist/network/http/readBody.d.ts +3 -0
- package/dist/network/http/readBody.js +112 -0
- package/dist/network/http/readBody.js.map +1 -0
- package/dist/network/http/send.d.ts +5 -0
- package/dist/network/http/send.js +60 -0
- package/dist/network/http/send.js.map +1 -0
- package/dist/network/http/streamFunction/DataStream.d.ts +7 -0
- package/dist/network/http/streamFunction/DataStream.js +19 -0
- package/dist/network/http/streamFunction/DataStream.js.map +1 -0
- package/dist/network/http/streamFunction/getExtension.d.ts +2 -0
- package/dist/network/http/streamFunction/getExtension.js +29 -0
- package/dist/network/http/streamFunction/getExtension.js.map +1 -0
- package/dist/network/http/streamFunction/index.d.ts +3 -0
- package/dist/network/http/streamFunction/index.js +81 -0
- package/dist/network/http/streamFunction/index.js.map +1 -0
- package/dist/network/http/streamFunction/multipartStream.d.ts +12 -0
- package/dist/network/http/streamFunction/multipartStream.js +208 -0
- package/dist/network/http/streamFunction/multipartStream.js.map +1 -0
- package/dist/network/http/streamFunction/stream.d.ts +5 -0
- package/dist/network/http/streamFunction/stream.js +103 -0
- package/dist/network/http/streamFunction/stream.js.map +1 -0
- package/dist/network/index.d.ts +4 -0
- package/dist/network/index.js +84 -0
- package/dist/network/index.js.map +1 -0
- package/dist/network/message/auth.d.ts +4 -0
- package/dist/network/message/auth.js +32 -0
- package/dist/network/message/auth.js.map +1 -0
- package/dist/network/message/function.d.ts +3 -0
- package/dist/network/message/function.js +67 -0
- package/dist/network/message/function.js.map +1 -0
- package/dist/network/message/get.d.ts +3 -0
- package/dist/network/message/get.js +109 -0
- package/dist/network/message/get.js.map +1 -0
- package/dist/network/message/index.d.ts +3 -0
- package/dist/network/message/index.js +62 -0
- package/dist/network/message/index.js.map +1 -0
- package/dist/network/message/observable.d.ts +5 -0
- package/dist/network/message/observable.js +103 -0
- package/dist/network/message/observable.js.map +1 -0
- package/dist/network/message/send.d.ts +4 -0
- package/dist/network/message/send.js +11 -0
- package/dist/network/message/send.js.map +1 -0
- package/dist/network/upgrade.d.ts +4 -0
- package/dist/network/upgrade.js +49 -0
- package/dist/network/upgrade.js.map +1 -0
- package/dist/network/worker/get.d.ts +0 -0
- package/dist/network/worker/get.js +122 -0
- package/dist/network/worker/get.js.map +1 -0
- package/dist/network/worker/observable.d.ts +0 -0
- package/dist/network/worker/observable.js +120 -0
- package/dist/network/worker/observable.js.map +1 -0
- package/dist/openListener.d.ts +4 -0
- package/dist/openListener.js +13 -0
- package/dist/openListener.js.map +1 -0
- package/dist/secrets.d.ts +9 -0
- package/dist/secrets.js +150 -0
- package/dist/secrets.js.map +1 -0
- package/dist/security/index.d.ts +3 -0
- package/dist/security/index.js +66 -0
- package/dist/security/index.js.map +1 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/upgradeListener.d.ts +4 -0
- package/dist/upgradeListener.js +47 -0
- package/dist/upgradeListener.js.map +1 -0
- package/dist/worker/authorize.d.ts +5 -0
- package/dist/worker/authorize.js +15 -0
- package/dist/worker/authorize.js.map +1 -0
- package/dist/worker/fnMap.d.ts +2 -0
- package/dist/worker/fnMap.js +5 -0
- package/dist/worker/fnMap.js.map +1 -0
- package/dist/worker/functions.d.ts +3 -0
- package/dist/worker/functions.js +8 -0
- package/dist/worker/functions.js.map +1 -0
- package/dist/worker/http/function.d.ts +4 -0
- package/dist/worker/http/function.js +75 -0
- package/dist/worker/http/function.js.map +1 -0
- package/dist/worker/index.d.ts +1 -0
- package/dist/worker/index.js +101 -0
- package/dist/worker/index.js.map +1 -0
- package/dist/worker/observable.d.ts +15 -0
- package/dist/worker/observable.js +110 -0
- package/dist/worker/observable.js.map +1 -0
- package/dist/worker/ws/function.d.ts +3 -0
- package/dist/worker/ws/function.js +42 -0
- package/dist/worker/ws/function.js.map +1 -0
- package/dist/workers/index.d.ts +0 -0
- package/dist/workers/index.js +20 -0
- package/dist/workers/index.js.map +1 -0
- package/dist/workers/workerCode.d.ts +12 -0
- package/dist/workers/workerCode.js +46 -0
- package/dist/workers/workerCode.js.map +1 -0
- package/package.json +1 -1
package/dist/Client.js
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Client = void 0;
|
|
7
|
+
const secrets_1 = require("./secrets");
|
|
8
|
+
const utils_1 = require("@saulx/utils");
|
|
9
|
+
const parseResponse_1 = __importDefault(require("./handlers/rest/parseResponse"));
|
|
10
|
+
const ua_parser_js_1 = __importDefault(require("ua-parser-js"));
|
|
11
|
+
let clientId = 0;
|
|
12
|
+
let totalBp = 0;
|
|
13
|
+
// make abstract class (rest client)
|
|
14
|
+
// why not make this user less new things that need to be made
|
|
15
|
+
class Client {
|
|
16
|
+
constructor(server, socket, res, type = 0) {
|
|
17
|
+
this.isBasedUser = false;
|
|
18
|
+
this.isApiKey = false;
|
|
19
|
+
this.id = ++clientId;
|
|
20
|
+
this._server = server;
|
|
21
|
+
if (socket) {
|
|
22
|
+
this.socket = socket;
|
|
23
|
+
socket.client = this;
|
|
24
|
+
}
|
|
25
|
+
this.type = type;
|
|
26
|
+
if (res) {
|
|
27
|
+
this.res = res;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
params(name) {
|
|
31
|
+
if (this._params) {
|
|
32
|
+
if (name) {
|
|
33
|
+
return this._params[name] || null;
|
|
34
|
+
}
|
|
35
|
+
return this._params;
|
|
36
|
+
}
|
|
37
|
+
const s = this.socket;
|
|
38
|
+
if (s) {
|
|
39
|
+
const params = {};
|
|
40
|
+
this._params = params;
|
|
41
|
+
try {
|
|
42
|
+
const arr = s.query.split(/\?|&/g);
|
|
43
|
+
for (const pair of arr) {
|
|
44
|
+
const [k, v = true] = pair.split('=');
|
|
45
|
+
params[k] = v;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (err) { }
|
|
49
|
+
if (name) {
|
|
50
|
+
return this._params[name] || null;
|
|
51
|
+
}
|
|
52
|
+
return this._params;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return name ? null : {};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
session(obj) {
|
|
59
|
+
if (!this._session) {
|
|
60
|
+
this._session = {};
|
|
61
|
+
}
|
|
62
|
+
if (obj) {
|
|
63
|
+
if (!obj || typeof obj !== 'object') {
|
|
64
|
+
console.error('Cannot set a non object on session');
|
|
65
|
+
return this._session;
|
|
66
|
+
}
|
|
67
|
+
(0, utils_1.deepMerge)(this._session, obj);
|
|
68
|
+
}
|
|
69
|
+
return this._session;
|
|
70
|
+
}
|
|
71
|
+
get ip() {
|
|
72
|
+
if (this._ip) {
|
|
73
|
+
return this._ip;
|
|
74
|
+
}
|
|
75
|
+
if (this.socket) {
|
|
76
|
+
return (this._ip = Buffer.from(this.socket.getRemoteAddressAsText()).toString());
|
|
77
|
+
}
|
|
78
|
+
if (this.res) {
|
|
79
|
+
return (this._ip = Buffer.from(this.res.getRemoteAddressAsText()).toString());
|
|
80
|
+
}
|
|
81
|
+
return '::1';
|
|
82
|
+
}
|
|
83
|
+
get ua() {
|
|
84
|
+
if (this._ua) {
|
|
85
|
+
return this._ua;
|
|
86
|
+
}
|
|
87
|
+
// UA Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
|
|
88
|
+
// fix the tablet etc
|
|
89
|
+
const ua = (this._ua = new ua_parser_js_1.default((this.socket ? this.socket.ua : this.res.ua) || '').getResult());
|
|
90
|
+
return ua;
|
|
91
|
+
}
|
|
92
|
+
setToken(token, opts) {
|
|
93
|
+
if (token) {
|
|
94
|
+
if (this._unpackedToken && this._token !== token) {
|
|
95
|
+
delete this._unpackedToken;
|
|
96
|
+
}
|
|
97
|
+
if (opts?.isApiKey) {
|
|
98
|
+
this.isApiKey = true;
|
|
99
|
+
}
|
|
100
|
+
else if (opts?.isBasedUser) {
|
|
101
|
+
this.isBasedUser = true;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.isBasedUser = false;
|
|
105
|
+
}
|
|
106
|
+
this._token = token;
|
|
107
|
+
if (opts?.refreshToken) {
|
|
108
|
+
this._refreshToken = opts.refreshToken;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.isApiKey = false;
|
|
113
|
+
this.isBasedUser = false;
|
|
114
|
+
if (this._unpackedToken) {
|
|
115
|
+
delete this._unpackedToken;
|
|
116
|
+
}
|
|
117
|
+
if (this._token) {
|
|
118
|
+
delete this._token;
|
|
119
|
+
}
|
|
120
|
+
if (this._refreshToken) {
|
|
121
|
+
delete this._refreshToken;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
get geo() {
|
|
126
|
+
if (this._geo) {
|
|
127
|
+
return this._geo;
|
|
128
|
+
}
|
|
129
|
+
const getGeo = this._server.config?.getGeo;
|
|
130
|
+
if (this._server.config?.getGeo) {
|
|
131
|
+
return (this._geo = getGeo(this.ip));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return {
|
|
135
|
+
iso: 'unkown',
|
|
136
|
+
regions: [],
|
|
137
|
+
long: 0,
|
|
138
|
+
lat: 0,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async token(secret, type = 'jwt') {
|
|
143
|
+
if (this._unpackedToken) {
|
|
144
|
+
return this._unpackedToken;
|
|
145
|
+
}
|
|
146
|
+
if (this._token) {
|
|
147
|
+
if (this.isApiKey) {
|
|
148
|
+
const getApiKeysPublicKey = this._server?.config?.getApiKeysPublicKey;
|
|
149
|
+
if (getApiKeysPublicKey) {
|
|
150
|
+
const apiTokensPublicKey = await getApiKeysPublicKey();
|
|
151
|
+
this._unpackedToken = await (0, secrets_1.decodeToken)(this._token, apiTokensPublicKey);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (this.isBasedUser) {
|
|
155
|
+
if (secret) {
|
|
156
|
+
throw new Error('Cannot validate based user with a custom secret');
|
|
157
|
+
}
|
|
158
|
+
const getBasedKey = this._server?.config?.getBasedKey;
|
|
159
|
+
if (getBasedKey) {
|
|
160
|
+
this._unpackedToken = await (0, secrets_1.decodeToken)(this._token, await getBasedKey());
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
console.warn('No getBasedKey defined');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else if (typeof secret === 'string') {
|
|
167
|
+
if (!secret) {
|
|
168
|
+
return this._token;
|
|
169
|
+
}
|
|
170
|
+
this._unpackedToken = await (0, secrets_1.decodeValueBySecret)(this._server, this._token, secret, type);
|
|
171
|
+
}
|
|
172
|
+
else if (typeof secret === 'object' && secret.publicKey) {
|
|
173
|
+
this._unpackedToken = await (0, secrets_1.decodeToken)(this._token, secret.publicKey);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
return this._token;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return this._unpackedToken;
|
|
180
|
+
}
|
|
181
|
+
drain() {
|
|
182
|
+
while (this.socket &&
|
|
183
|
+
!this.closed &&
|
|
184
|
+
!this.socket.getBufferedAmount() &&
|
|
185
|
+
this.backpressureQueue?.length) {
|
|
186
|
+
totalBp--;
|
|
187
|
+
const [payload, time] = this.backpressureQueue.shift();
|
|
188
|
+
if (Date.now() - time > 10e3) {
|
|
189
|
+
this.backpressureQueue = [];
|
|
190
|
+
console.info('last bp is larger then 10 seconds destroy client');
|
|
191
|
+
this.destroy();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (!this.socket.send(JSON.stringify(payload))) {
|
|
195
|
+
console.info('drain build bp --- ', this.backpressureQueue.length, 'length in queue still');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// totalBpQ
|
|
199
|
+
if (this.backpressureQueue?.length === 0) {
|
|
200
|
+
this.backpressureQueue = null;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
send(payload, headers) {
|
|
204
|
+
// here we are going to add checksum ALLWAYS
|
|
205
|
+
if (this.res) {
|
|
206
|
+
(0, parseResponse_1.default)(this.res, payload, this.type, undefined, headers);
|
|
207
|
+
this.destroy();
|
|
208
|
+
}
|
|
209
|
+
else if (!this.closed && this.socket) {
|
|
210
|
+
if (this.socket.getBufferedAmount()) {
|
|
211
|
+
if (!this.backpressureQueue) {
|
|
212
|
+
this.backpressureQueue = [];
|
|
213
|
+
}
|
|
214
|
+
if (this.backpressureQueue.length) {
|
|
215
|
+
const time = this.backpressureQueue[0][1];
|
|
216
|
+
if (Date.now() - time > 10e3) {
|
|
217
|
+
this.backpressureQueue = [];
|
|
218
|
+
console.info('last bp is larger then 10 seconds destory');
|
|
219
|
+
this.destroy();
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
totalBp++;
|
|
224
|
+
if (totalBp > 5e3) {
|
|
225
|
+
console.info('Too much bp EXIT process');
|
|
226
|
+
process.exit();
|
|
227
|
+
}
|
|
228
|
+
this.backpressureQueue.push([payload, Date.now()]);
|
|
229
|
+
if (this.backpressureQueue.length > 50) {
|
|
230
|
+
this.backpressureQueue = [];
|
|
231
|
+
console.info('too large bp destroy client');
|
|
232
|
+
this.destroy();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
console.info('add to bp queue', this.backpressureQueue.length, this.socket.getBufferedAmount());
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
// lets do better with backpressure
|
|
239
|
+
// buffer directly?
|
|
240
|
+
if (typeof payload === 'string') {
|
|
241
|
+
this.socket.send(payload);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
this.socket.send(JSON.stringify(payload));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
console.info('Not sending socket is closed ', !!this.socket, this.closed);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
destroy(socketClosed) {
|
|
253
|
+
this.closed = true;
|
|
254
|
+
if (this.backpressureQueue && this.backpressureQueue.length) {
|
|
255
|
+
totalBp -= this.backpressureQueue.length;
|
|
256
|
+
this.backpressureQueue = [];
|
|
257
|
+
}
|
|
258
|
+
if (this.subscriptions) {
|
|
259
|
+
for (const id in this.subscriptions) {
|
|
260
|
+
this.subscriptions[id].unsubscribe(this);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (this.socket) {
|
|
264
|
+
this.socket.client = null;
|
|
265
|
+
if (!socketClosed) {
|
|
266
|
+
this.socket.end();
|
|
267
|
+
}
|
|
268
|
+
this.socket = null;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
this.res = null;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
exports.Client = Client;
|
|
276
|
+
exports.default = Client;
|
|
277
|
+
//# sourceMappingURL=Client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":";;;;;;AAOA,uCAA4D;AAE5D,wCAAwC;AACxC,kFAAyD;AAGzD,gEAAmC;AAGnC,IAAI,QAAQ,GAAG,CAAC,CAAA;AAEhB,IAAI,OAAO,GAAG,CAAC,CAAA;AAWf,oCAAoC;AAEpC,8DAA8D;AAC9D,MAAa,MAAM;IA+FjB,YACE,MAAmB,EACnB,MAAsB,EACtB,GAAsB,EACtB,OAAc,CAAC;QA3DV,gBAAW,GAAY,KAAK,CAAA;QAE5B,aAAQ,GAAY,KAAK,CAAA;QA2D9B,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QAErB,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;YACpB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAA;SAC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.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { BasedServer } from './';
|
|
3
|
+
import BasedServerClient from './BasedServerClient';
|
|
4
|
+
import { Client } from './Client';
|
|
5
|
+
import { Readable } from 'stream';
|
|
6
|
+
export declare class Params {
|
|
7
|
+
constructor(server: BasedServer, payload?: any, user?: Client, callStack?: string[], update?: (value: any, checksum?: number) => void, name?: string, type?: string, useGlobalBased?: boolean, stream?: Readable);
|
|
8
|
+
private useGlobalBased?;
|
|
9
|
+
type?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
update: (value: any, checksum?: number) => void;
|
|
12
|
+
callStack: string[];
|
|
13
|
+
user: Client;
|
|
14
|
+
payload?: any;
|
|
15
|
+
fileStream?: Readable;
|
|
16
|
+
private _based;
|
|
17
|
+
server: BasedServer;
|
|
18
|
+
path?: string;
|
|
19
|
+
get based(): BasedServerClient;
|
|
20
|
+
}
|
package/dist/Params.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Params = void 0;
|
|
7
|
+
const BasedServerClient_1 = __importDefault(require("./BasedServerClient"));
|
|
8
|
+
class Params {
|
|
9
|
+
constructor(server, payload, user, callStack, update, name, type, useGlobalBased = false, stream = null) {
|
|
10
|
+
this.update = (value, checksum) => {
|
|
11
|
+
console.warn('cannot use update on a non-observable function', value, checksum);
|
|
12
|
+
};
|
|
13
|
+
this.server = server;
|
|
14
|
+
if (callStack) {
|
|
15
|
+
this.callStack = callStack;
|
|
16
|
+
}
|
|
17
|
+
if (user) {
|
|
18
|
+
this.user = user;
|
|
19
|
+
}
|
|
20
|
+
if (stream) {
|
|
21
|
+
this.fileStream = stream;
|
|
22
|
+
}
|
|
23
|
+
if (update) {
|
|
24
|
+
this.update = update;
|
|
25
|
+
}
|
|
26
|
+
if (name) {
|
|
27
|
+
this.name = name;
|
|
28
|
+
}
|
|
29
|
+
if (type) {
|
|
30
|
+
this.type = type;
|
|
31
|
+
}
|
|
32
|
+
this.payload = payload;
|
|
33
|
+
if (useGlobalBased) {
|
|
34
|
+
this.useGlobalBased = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
get based() {
|
|
38
|
+
if (this.useGlobalBased) {
|
|
39
|
+
return this.server.based;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return this._based || (this._based = new BasedServerClient_1.default(this));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.Params = Params;
|
|
47
|
+
Params.prototype.callStack = [];
|
|
48
|
+
//# sourceMappingURL=Params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Params.js","sourceRoot":"","sources":["../src/Params.ts"],"names":[],"mappings":";;;;;;AACA,4EAAmD;AAInD,MAAa,MAAM;IACjB,YACE,MAAmB,EACnB,OAAa,EACb,IAAa,EACb,SAAoB,EACpB,MAAgD,EAChD,IAAa,EACb,IAAa,EACb,iBAA0B,KAAK,EAC/B,SAAmB,IAAI;QAkClB,WAAM,GAA4C,CACvD,KAAU,EACV,QAAiB,EACjB,EAAE;YACF,OAAO,CAAC,IAAI,CACV,gDAAgD,EAChD,KAAK,EACL,QAAQ,CACT,CAAA;QACH,CAAC,CAAA;QAzCC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,SAAS,EAAE;YACb,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;SAC3B;QACD,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;SACjB;QACD,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA;SACzB;QACD,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;SACrB;QACD,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;SACjB;QACD,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;SACjB;QACD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QAEtB,IAAI,cAAc,EAAE;YAClB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;SAC3B;IACH,CAAC;IAiCD,IAAI,KAAK;QACP,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAA;SACzB;aAAM;YACL,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,2BAAiB,CAAC,IAAI,CAAC,CAAC,CAAA;SAClE;IACH,CAAC;CACF;AA5ED,wBA4EC;AAED,MAAM,CAAC,SAAS,CAAC,SAAS,GAAG,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../src/auth/authorize.ts"],"names":[],"mappings":";;;AAEO,MAAM,SAAS,GAAc,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAC1E,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAFY,QAAA,SAAS,aAErB"}
|
|
File without changes
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// import { hash } from '@saulx/hash'
|
|
2
|
+
/*
|
|
3
|
+
sharedArrayBuffer UA
|
|
4
|
+
// make a ua table and hash UA
|
|
5
|
+
// ip just in buffer format
|
|
6
|
+
// 250 bytes
|
|
7
|
+
*/
|
|
8
|
+
// export const readIpFromContext = () => {
|
|
9
|
+
// // what to read
|
|
10
|
+
// // ip
|
|
11
|
+
// // ua
|
|
12
|
+
// // id
|
|
13
|
+
// // authState
|
|
14
|
+
// /*
|
|
15
|
+
// function bytesToNumber(byteArray) {
|
|
16
|
+
// let result = 0;
|
|
17
|
+
// for (let i = byteArray.length - 1; i >= 0; i--) {
|
|
18
|
+
// result = (result * 256) + byteArray[i];
|
|
19
|
+
// }
|
|
20
|
+
// return result;
|
|
21
|
+
// }
|
|
22
|
+
// */
|
|
23
|
+
// }
|
|
24
|
+
// export const readUaFromContext = () => {}
|
|
25
|
+
// export const readQueryFromContext = () => {}
|
|
26
|
+
// export const readEncodingFromContext = () => {}
|
|
27
|
+
// export const readAuthStateFromContext = () => {}
|
|
28
|
+
// /*
|
|
29
|
+
// export type ClientContext = {
|
|
30
|
+
// query: string
|
|
31
|
+
// ua: string
|
|
32
|
+
// ip: string
|
|
33
|
+
// id: number
|
|
34
|
+
// authState?: any
|
|
35
|
+
// method: string // this will be removed
|
|
36
|
+
// headers: {
|
|
37
|
+
// 'content-length'?: number
|
|
38
|
+
// authorization?: string
|
|
39
|
+
// 'content-type'?: string
|
|
40
|
+
// 'content-encoding'?: string
|
|
41
|
+
// encoding?: string
|
|
42
|
+
// }
|
|
43
|
+
// }
|
|
44
|
+
// */
|
|
45
|
+
// const encoder = new TextEncoder()
|
|
46
|
+
// export const createContext = (
|
|
47
|
+
// ip: ArrayBuffer,
|
|
48
|
+
// ua: string,
|
|
49
|
+
// query: string,
|
|
50
|
+
// authState: any, // maybe add refresh and token (token can then have )
|
|
51
|
+
// forwardedFor: string,
|
|
52
|
+
// outgoingEncoding: string
|
|
53
|
+
// ): Uint8Array => {
|
|
54
|
+
// // IP 16 bytes
|
|
55
|
+
// // UA 8 bytes
|
|
56
|
+
// // ENCODING 1 byte (in & out)
|
|
57
|
+
// // forwarded for needs to be parsed to 16 bytes ipv6
|
|
58
|
+
// let len = 16 + 8 + 1
|
|
59
|
+
// const encodedQuery = encoder.encode(query)
|
|
60
|
+
// len += encodedQuery.byteLength
|
|
61
|
+
// const sharedBuffer = new SharedArrayBuffer(len)
|
|
62
|
+
// const view = new Uint8Array(sharedBuffer)
|
|
63
|
+
// view.set(new Uint8Array(ip), 0)
|
|
64
|
+
// const uaHash = hash(ua)
|
|
65
|
+
// let n = uaHash
|
|
66
|
+
// for (let index = 16; index < 32; index++) {
|
|
67
|
+
// const byte = n & 0xff
|
|
68
|
+
// view[index] = byte
|
|
69
|
+
// n = (n - byte) / 256
|
|
70
|
+
// }
|
|
71
|
+
// // typeof auth state is {} with refresh token and token
|
|
72
|
+
// // then
|
|
73
|
+
// // parse encoding
|
|
74
|
+
// view[32] = outgoingEncoding.includes('deflate')
|
|
75
|
+
// ? 1
|
|
76
|
+
// : outgoingEncoding.includes('gzip')
|
|
77
|
+
// ? 2
|
|
78
|
+
// : outgoingEncoding.includes('br')
|
|
79
|
+
// ? 3
|
|
80
|
+
// : 0
|
|
81
|
+
// return view
|
|
82
|
+
// }
|
|
83
|
+
//# sourceMappingURL=clientContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientContext.js","sourceRoot":"","sources":["../src/clientContext.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC;;;;;IAKI;AAEJ,2CAA2C;AAC3C,oBAAoB;AACpB,UAAU;AACV,UAAU;AACV,UAAU;AACV,iBAAiB;AACjB,OAAO;AACP,wCAAwC;AACxC,sBAAsB;AACtB,wDAAwD;AACxD,kDAAkD;AAClD,QAAQ;AACR,qBAAqB;AACrB,IAAI;AACJ,OAAO;AACP,IAAI;AAEJ,4CAA4C;AAE5C,+CAA+C;AAE/C,kDAAkD;AAElD,mDAAmD;AAEnD,KAAK;AACL,gCAAgC;AAChC,kBAAkB;AAClB,eAAe;AACf,eAAe;AACf,eAAe;AACf,oBAAoB;AACpB,4CAA4C;AAC5C,eAAe;AACf,gCAAgC;AAChC,6BAA6B;AAC7B,8BAA8B;AAC9B,kCAAkC;AAClC,wBAAwB;AACxB,MAAM;AACN,IAAI;AACJ,KAAK;AAEL,oCAAoC;AAEpC,iCAAiC;AACjC,qBAAqB;AACrB,gBAAgB;AAChB,mBAAmB;AACnB,0EAA0E;AAC1E,0BAA0B;AAC1B,6BAA6B;AAC7B,qBAAqB;AACrB,mBAAmB;AACnB,kBAAkB;AAClB,kCAAkC;AAElC,yDAAyD;AACzD,yBAAyB;AAEzB,+CAA+C;AAE/C,mCAAmC;AAEnC,oDAAoD;AAEpD,8CAA8C;AAE9C,oCAAoC;AAEpC,4BAA4B;AAE5B,mBAAmB;AACnB,gDAAgD;AAChD,4BAA4B;AAC5B,yBAAyB;AACzB,2BAA2B;AAC3B,MAAM;AAEN,4DAA4D;AAC5D,YAAY;AAEZ,sBAAsB;AACtB,oDAAoD;AACpD,UAAU;AACV,0CAA0C;AAC1C,UAAU;AACV,wCAAwC;AACxC,UAAU;AACV,UAAU;AAEV,gBAAgB;AAChB,IAAI"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const close = (server, socket) => {
|
|
4
|
+
if (!socket.client) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const client = socket.client;
|
|
8
|
+
server.emit('close', client);
|
|
9
|
+
delete server.clients[client.id];
|
|
10
|
+
client.destroy(true);
|
|
11
|
+
};
|
|
12
|
+
exports.default = close;
|
|
13
|
+
//# sourceMappingURL=closeListener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closeListener.js","sourceRoot":"","sources":["../src/closeListener.ts"],"names":[],"mappings":";;AAGA,MAAM,KAAK,GAAG,CAAC,MAAmB,EAAE,MAAqB,EAAE,EAAE;IAC3D,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;QAClB,OAAM;KACP;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IAC5B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC5B,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAChC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AACtB,CAAC,CAAA;AAED,kBAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AuthConfig } from './auth';
|
|
2
|
+
import { BasedFunction, BasedFunctionSpec, BasedObservableFunction, BasedObservableFunctionSpec } from './functions';
|
|
3
|
+
import { BasedServer } from './server';
|
|
4
|
+
export declare type SimpleServerOptions = {
|
|
5
|
+
port?: number;
|
|
6
|
+
key?: string;
|
|
7
|
+
cert?: string;
|
|
8
|
+
auth?: AuthConfig;
|
|
9
|
+
functions?: {
|
|
10
|
+
[key: string]: BasedFunction | (Partial<BasedFunctionSpec> & {
|
|
11
|
+
function: BasedFunction;
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
observables?: {
|
|
15
|
+
[key: string]: BasedObservableFunction | (Partial<BasedObservableFunctionSpec> & {
|
|
16
|
+
function: BasedObservableFunction;
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function createSimpleServer(props: SimpleServerOptions, sharedSocket?: boolean): Promise<BasedServer>;
|
|
21
|
+
export declare function isFunctionSpec(fn: BasedFunction | Partial<BasedFunctionSpec>): fn is Partial<BasedFunctionSpec>;
|
|
22
|
+
export declare function isObsFunctionSpec(fn: BasedObservableFunction | Partial<BasedObservableFunctionSpec>): fn is Partial<BasedObservableFunctionSpec>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isObsFunctionSpec = exports.isFunctionSpec = exports.createSimpleServer = void 0;
|
|
4
|
+
const server_1 = require("./server");
|
|
5
|
+
async function createSimpleServer(props, sharedSocket) {
|
|
6
|
+
const { functions, observables } = props;
|
|
7
|
+
const functionStore = {};
|
|
8
|
+
for (const name in functions) {
|
|
9
|
+
if (functions[name]) {
|
|
10
|
+
const fn = functions[name];
|
|
11
|
+
if (isFunctionSpec(fn)) {
|
|
12
|
+
functionStore[name] = {
|
|
13
|
+
function: fn.function,
|
|
14
|
+
path: `/${name}`,
|
|
15
|
+
name,
|
|
16
|
+
observable: false,
|
|
17
|
+
checksum: 1,
|
|
18
|
+
maxPayloadSize: 5e3,
|
|
19
|
+
rateLimitTokens: 1,
|
|
20
|
+
...fn,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
functionStore[name] = {
|
|
25
|
+
function: fn,
|
|
26
|
+
path: `/${name}`,
|
|
27
|
+
name,
|
|
28
|
+
observable: false,
|
|
29
|
+
checksum: 1,
|
|
30
|
+
maxPayloadSize: 5e3,
|
|
31
|
+
rateLimitTokens: 1,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const name in observables) {
|
|
37
|
+
if (observables[name]) {
|
|
38
|
+
const fn = observables[name];
|
|
39
|
+
if (isObsFunctionSpec(fn)) {
|
|
40
|
+
functionStore[name] = {
|
|
41
|
+
checksum: 1,
|
|
42
|
+
observable: true,
|
|
43
|
+
function: fn.function,
|
|
44
|
+
path: `/${name}`,
|
|
45
|
+
name,
|
|
46
|
+
maxPayloadSize: 500,
|
|
47
|
+
rateLimitTokens: 5,
|
|
48
|
+
...fn,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
functionStore[name] = {
|
|
53
|
+
checksum: 1,
|
|
54
|
+
observable: true,
|
|
55
|
+
function: fn,
|
|
56
|
+
name,
|
|
57
|
+
path: `/${name}`,
|
|
58
|
+
maxPayloadSize: 500,
|
|
59
|
+
rateLimitTokens: 5,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const properProps = {
|
|
65
|
+
port: props.port,
|
|
66
|
+
auth: props.auth,
|
|
67
|
+
cert: props.cert,
|
|
68
|
+
functions: {
|
|
69
|
+
memCacheTimeout: 3e3,
|
|
70
|
+
idleTimeout: 1e3,
|
|
71
|
+
uninstall: async () => {
|
|
72
|
+
return true;
|
|
73
|
+
},
|
|
74
|
+
install: async ({ name }) => {
|
|
75
|
+
if (functionStore[name]) {
|
|
76
|
+
return functionStore[name];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
route: ({ path, name }) => {
|
|
83
|
+
if (path) {
|
|
84
|
+
for (const name in functionStore) {
|
|
85
|
+
if (functionStore[name].path === path) {
|
|
86
|
+
return functionStore[name];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (functionStore[name]) {
|
|
91
|
+
return functionStore[name];
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
console.info('Server starting with the following functions:');
|
|
98
|
+
for (const name in functionStore) {
|
|
99
|
+
console.info({
|
|
100
|
+
name: functionStore[name].name,
|
|
101
|
+
path: functionStore[name].path,
|
|
102
|
+
observable: functionStore[name].observable,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const basedServer = new server_1.BasedServer(properProps);
|
|
106
|
+
return props.port ? basedServer.start(props.port, sharedSocket) : basedServer;
|
|
107
|
+
}
|
|
108
|
+
exports.createSimpleServer = createSimpleServer;
|
|
109
|
+
// function simpleFuncToNormal(
|
|
110
|
+
// fn: (payload: any, ctx: Context) => any | Partial<BasedFunctionSpec>
|
|
111
|
+
// ): BasedFunctionSpec {}
|
|
112
|
+
function isFunctionSpec(fn) {
|
|
113
|
+
return 'function' in fn || false;
|
|
114
|
+
}
|
|
115
|
+
exports.isFunctionSpec = isFunctionSpec;
|
|
116
|
+
function isObsFunctionSpec(fn) {
|
|
117
|
+
return 'function' in fn || false;
|
|
118
|
+
}
|
|
119
|
+
exports.isObsFunctionSpec = isObsFunctionSpec;
|
|
120
|
+
//# sourceMappingURL=createSimpleServer.js.map
|
|
@@ -0,0 +1 @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