@tramvai/module-server 3.26.3 → 3.27.0
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/lib/server/server.d.ts +2 -1
- package/lib/server/server.es.js +12 -1
- package/lib/server/server.js +13 -1
- package/lib/server.es.js +5 -1
- package/lib/server.js +5 -1
- package/package.json +15 -15
package/lib/server/server.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
|
+
import https from 'https';
|
|
2
3
|
import type { SERVER_TOKEN } from '@tramvai/tokens-server';
|
|
3
4
|
import type { LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
4
5
|
import type { ENV_MANAGER_TOKEN } from '@tramvai/module-environment';
|
|
5
|
-
export declare const serverFactory: () => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
6
|
+
export declare const serverFactory: () => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | https.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
6
7
|
export declare const serverListenCommand: ({ server, logger, envManager, }: {
|
|
7
8
|
server: typeof SERVER_TOKEN;
|
|
8
9
|
logger: typeof LOGGER_TOKEN;
|
package/lib/server/server.es.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
|
+
import https from 'https';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
2
4
|
|
|
3
5
|
const serverFactory = () => {
|
|
6
|
+
var _a;
|
|
7
|
+
const httpsOptions = JSON.parse((_a = process.env.HTTPS) !== null && _a !== void 0 ? _a : null);
|
|
8
|
+
if (httpsOptions && httpsOptions.key && httpsOptions.cert) {
|
|
9
|
+
return https.createServer({
|
|
10
|
+
key: readFileSync(httpsOptions.key),
|
|
11
|
+
cert: readFileSync(httpsOptions.cert),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
4
14
|
return http.createServer();
|
|
5
15
|
};
|
|
6
16
|
const serverListenCommand = ({ server, logger, envManager, }) => {
|
|
7
17
|
const log = logger('server');
|
|
8
18
|
const port = envManager.get('PORT');
|
|
19
|
+
const host = envManager.get('HOST');
|
|
9
20
|
return function serverListen() {
|
|
10
21
|
server.listen({
|
|
11
|
-
host
|
|
22
|
+
host,
|
|
12
23
|
port,
|
|
13
24
|
}, () => log.warn({ event: 'server-listen-port', message: `Server listen ${port} port` }));
|
|
14
25
|
};
|
package/lib/server/server.js
CHANGED
|
@@ -3,20 +3,32 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var http = require('http');
|
|
6
|
+
var https = require('https');
|
|
7
|
+
var fs = require('fs');
|
|
6
8
|
|
|
7
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
10
|
|
|
9
11
|
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
12
|
+
var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
|
|
10
13
|
|
|
11
14
|
const serverFactory = () => {
|
|
15
|
+
var _a;
|
|
16
|
+
const httpsOptions = JSON.parse((_a = process.env.HTTPS) !== null && _a !== void 0 ? _a : null);
|
|
17
|
+
if (httpsOptions && httpsOptions.key && httpsOptions.cert) {
|
|
18
|
+
return https__default["default"].createServer({
|
|
19
|
+
key: fs.readFileSync(httpsOptions.key),
|
|
20
|
+
cert: fs.readFileSync(httpsOptions.cert),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
12
23
|
return http__default["default"].createServer();
|
|
13
24
|
};
|
|
14
25
|
const serverListenCommand = ({ server, logger, envManager, }) => {
|
|
15
26
|
const log = logger('server');
|
|
16
27
|
const port = envManager.get('PORT');
|
|
28
|
+
const host = envManager.get('HOST');
|
|
17
29
|
return function serverListen() {
|
|
18
30
|
server.listen({
|
|
19
|
-
host
|
|
31
|
+
host,
|
|
20
32
|
port,
|
|
21
33
|
}, () => log.warn({ event: 'server-listen-port', message: `Server listen ${port} port` }));
|
|
22
34
|
};
|
package/lib/server.es.js
CHANGED
|
@@ -61,7 +61,9 @@ ServerModule = __decorate([
|
|
|
61
61
|
provide({
|
|
62
62
|
provide: SERVER_TOKEN,
|
|
63
63
|
scope: Scope.SINGLETON,
|
|
64
|
-
useFactory: ({ factory }) =>
|
|
64
|
+
useFactory: ({ factory }) => {
|
|
65
|
+
return factory();
|
|
66
|
+
},
|
|
65
67
|
deps: {
|
|
66
68
|
factory: SERVER_FACTORY_TOKEN,
|
|
67
69
|
},
|
|
@@ -160,6 +162,8 @@ ServerModule = __decorate([
|
|
|
160
162
|
{ key: 'DEPLOY_COMMIT', optional: true, dehydrate: false },
|
|
161
163
|
{ key: 'DEPLOY_VERSION', optional: true, dehydrate: false },
|
|
162
164
|
{ key: 'DEPLOY_REPOSITORY', optional: true, dehydrate: false },
|
|
165
|
+
{ key: 'HOST', optional: true, dehydrate: false, value: process.env.HOST },
|
|
166
|
+
{ key: 'HTTPS', optional: true, dehydrate: false, value: process.env.HTTPS },
|
|
163
167
|
],
|
|
164
168
|
},
|
|
165
169
|
{
|
package/lib/server.js
CHANGED
|
@@ -68,7 +68,9 @@ exports.ServerModule = tslib.__decorate([
|
|
|
68
68
|
core.provide({
|
|
69
69
|
provide: tokensServer.SERVER_TOKEN,
|
|
70
70
|
scope: core.Scope.SINGLETON,
|
|
71
|
-
useFactory: ({ factory }) =>
|
|
71
|
+
useFactory: ({ factory }) => {
|
|
72
|
+
return factory();
|
|
73
|
+
},
|
|
72
74
|
deps: {
|
|
73
75
|
factory: tokensServerPrivate.SERVER_FACTORY_TOKEN,
|
|
74
76
|
},
|
|
@@ -167,6 +169,8 @@ exports.ServerModule = tslib.__decorate([
|
|
|
167
169
|
{ key: 'DEPLOY_COMMIT', optional: true, dehydrate: false },
|
|
168
170
|
{ key: 'DEPLOY_VERSION', optional: true, dehydrate: false },
|
|
169
171
|
{ key: 'DEPLOY_REPOSITORY', optional: true, dehydrate: false },
|
|
172
|
+
{ key: 'HOST', optional: true, dehydrate: false, value: process.env.HOST },
|
|
173
|
+
{ key: 'HTTPS', optional: true, dehydrate: false, value: process.env.HTTPS },
|
|
170
174
|
],
|
|
171
175
|
},
|
|
172
176
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.27.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"@tinkoff/monkeypatch": "3.0.1",
|
|
27
27
|
"@tinkoff/terminus": "0.2.1",
|
|
28
28
|
"@tinkoff/url": "0.9.2",
|
|
29
|
-
"@tramvai/module-cache-warmup": "3.
|
|
30
|
-
"@tramvai/module-metrics": "3.
|
|
31
|
-
"@tramvai/papi": "3.
|
|
32
|
-
"@tramvai/tokens-server": "3.
|
|
33
|
-
"@tramvai/tokens-router": "3.
|
|
34
|
-
"@tramvai/tokens-server-private": "3.
|
|
29
|
+
"@tramvai/module-cache-warmup": "3.27.0",
|
|
30
|
+
"@tramvai/module-metrics": "3.27.0",
|
|
31
|
+
"@tramvai/papi": "3.27.0",
|
|
32
|
+
"@tramvai/tokens-server": "3.27.0",
|
|
33
|
+
"@tramvai/tokens-router": "3.27.0",
|
|
34
|
+
"@tramvai/tokens-server-private": "3.27.0",
|
|
35
35
|
"@tramvai/safe-strings": "0.6.2",
|
|
36
36
|
"fastify": "^4.14.1",
|
|
37
37
|
"@fastify/cookie": "^8.3.0",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@tinkoff/dippy": "0.9.2",
|
|
46
46
|
"@tinkoff/utils": "^2.1.2",
|
|
47
|
-
"@tramvai/cli": "3.
|
|
48
|
-
"@tramvai/core": "3.
|
|
49
|
-
"@tramvai/react": "3.
|
|
50
|
-
"@tramvai/module-common": "3.
|
|
51
|
-
"@tramvai/module-environment": "3.
|
|
52
|
-
"@tramvai/tokens-common": "3.
|
|
53
|
-
"@tramvai/tokens-core-private": "3.
|
|
54
|
-
"@tramvai/tokens-render": "3.
|
|
47
|
+
"@tramvai/cli": "3.27.0",
|
|
48
|
+
"@tramvai/core": "3.27.0",
|
|
49
|
+
"@tramvai/react": "3.27.0",
|
|
50
|
+
"@tramvai/module-common": "3.27.0",
|
|
51
|
+
"@tramvai/module-environment": "3.27.0",
|
|
52
|
+
"@tramvai/tokens-common": "3.27.0",
|
|
53
|
+
"@tramvai/tokens-core-private": "3.27.0",
|
|
54
|
+
"@tramvai/tokens-render": "3.27.0",
|
|
55
55
|
"react": ">=16.14.0",
|
|
56
56
|
"react-dom": ">=16.14.0",
|
|
57
57
|
"tslib": "^2.4.0"
|