@tramvai/module-server 1.94.0 → 1.94.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/lib/server/webApp.d.ts +2 -2
- package/lib/server.es.js +77 -72
- package/lib/server.js +76 -71
- package/package.json +12 -12
package/lib/server/webApp.d.ts
CHANGED
|
@@ -9,15 +9,15 @@ export declare const webAppFactory: ({ server }: {
|
|
|
9
9
|
export declare const webAppExpressFactory: ({ webApp }: {
|
|
10
10
|
webApp: typeof WEB_FASTIFY_APP_TOKEN;
|
|
11
11
|
}) => import("express-serve-static-core").Express;
|
|
12
|
-
export declare const webAppInitCommand: ({ app, expressApp, logger, commandLineRunner, beforeInit, init, afterInit,
|
|
12
|
+
export declare const webAppInitCommand: ({ app, expressApp, logger, commandLineRunner, beforeInit, limiterRequest, init, afterInit, expressBeforeInit, expressInit, expressAfterInit, expressLimiterRequest, beforeError, processError, afterError, }: {
|
|
13
13
|
app: typeof WEB_FASTIFY_APP_TOKEN;
|
|
14
14
|
expressApp: typeof WEB_APP_TOKEN;
|
|
15
15
|
logger: typeof LOGGER_TOKEN;
|
|
16
16
|
commandLineRunner: typeof COMMAND_LINE_RUNNER_TOKEN;
|
|
17
17
|
beforeInit: typeof WEB_FASTIFY_APP_BEFORE_INIT_TOKEN;
|
|
18
|
+
limiterRequest: typeof WEB_FASTIFY_APP_LIMITER_TOKEN;
|
|
18
19
|
init: typeof WEB_FASTIFY_APP_INIT_TOKEN;
|
|
19
20
|
afterInit: typeof WEB_FASTIFY_APP_AFTER_INIT_TOKEN;
|
|
20
|
-
limiterRequest: typeof WEB_FASTIFY_APP_LIMITER_TOKEN;
|
|
21
21
|
expressBeforeInit: typeof WEB_APP_BEFORE_INIT_TOKEN;
|
|
22
22
|
expressInit: typeof WEB_APP_INIT_TOKEN;
|
|
23
23
|
expressAfterInit: typeof WEB_APP_AFTER_INIT_TOKEN;
|
package/lib/server.es.js
CHANGED
|
@@ -2,7 +2,7 @@ import { __decorate } from 'tslib';
|
|
|
2
2
|
import { Scope, APP_INFO_TOKEN, Module, provide, DI_TOKEN, COMMAND_LINE_RUNNER_TOKEN, commandLineListTokens } from '@tramvai/core';
|
|
3
3
|
import { SERVER_MODULE_PAPI_PUBLIC_ROUTE, SERVER_MODULE_PAPI_PUBLIC_URL, SERVER_MODULE_PAPI_PRIVATE_URL, WEB_APP_BEFORE_INIT_TOKEN, WEB_APP_TOKEN, SERVER_MODULE_PAPI_PRIVATE_ROUTE, SERVER_MODULE_STATICS_OPTIONS, SERVER_TOKEN, READINESS_PROBE_TOKEN, LIVENESS_PROBE_TOKEN, SPECIAL_SERVER_PATHS, PROXY_CONFIG_TOKEN, DEPENDENCIES_VERSION_FILTER_TOKEN, WEB_APP_INIT_TOKEN, WEB_APP_AFTER_INIT_TOKEN, WEB_APP_LIMITER_TOKEN } from '@tramvai/tokens-server';
|
|
4
4
|
export * from '@tramvai/tokens-server';
|
|
5
|
-
import { WEB_FASTIFY_APP_BEFORE_INIT_TOKEN,
|
|
5
|
+
import { WEB_FASTIFY_APP_BEFORE_INIT_TOKEN, SERVER_FACTORY_TOKEN, WEB_FASTIFY_APP_FACTORY_TOKEN, WEB_FASTIFY_APP_TOKEN, WEB_FASTIFY_APP_INIT_TOKEN, WEB_FASTIFY_APP_AFTER_INIT_TOKEN, WEB_FASTIFY_APP_LIMITER_TOKEN, WEB_FASTIFY_APP_BEFORE_ERROR_TOKEN, WEB_FASTIFY_APP_PROCESS_ERROR_TOKEN, WEB_FASTIFY_APP_AFTER_ERROR_TOKEN } from '@tramvai/tokens-server-private';
|
|
6
6
|
import { REQUEST, RESPONSE, FASTIFY_REQUEST, FASTIFY_RESPONSE, RESPONSE_MANAGER_TOKEN, LOGGER_TOKEN, ENV_MANAGER_TOKEN, ENV_USED_TOKEN } from '@tramvai/tokens-common';
|
|
7
7
|
import { MetricsModule } from '@tramvai/module-metrics';
|
|
8
8
|
import { CacheWarmupModule } from '@tramvai/module-cache-warmup';
|
|
@@ -116,10 +116,11 @@ const expressPlugin = (fastify, options, next) => {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
function onRegister(instance) {
|
|
119
|
+
var _a, _b;
|
|
119
120
|
const middlewares = instance[kMiddlewares].slice();
|
|
120
121
|
// eslint-disable-next-line no-param-reassign
|
|
121
122
|
instance[kMiddlewares] = [];
|
|
122
|
-
instance.decorate('express', express());
|
|
123
|
+
instance.decorate('express', (_b = (_a = options.express) === null || _a === void 0 ? void 0 : _a.instance) !== null && _b !== void 0 ? _b : express());
|
|
123
124
|
instance.express.disable('x-powered-by');
|
|
124
125
|
instance.decorate('use', use);
|
|
125
126
|
for (const middleware of middlewares) {
|
|
@@ -198,11 +199,11 @@ const webAppExpressFactory = ({ webApp }) => {
|
|
|
198
199
|
app.disable('x-powered-by');
|
|
199
200
|
return app;
|
|
200
201
|
};
|
|
201
|
-
const webAppInitCommand = ({ app, expressApp, logger, commandLineRunner, beforeInit, init, afterInit,
|
|
202
|
+
const webAppInitCommand = ({ app, expressApp, logger, commandLineRunner, beforeInit, limiterRequest, init, afterInit, expressBeforeInit, expressInit, expressAfterInit, expressLimiterRequest, beforeError, processError, afterError, }) => {
|
|
202
203
|
const log = logger('server:webapp');
|
|
203
|
-
const runHandlers = (handlers, expressHandlers) => {
|
|
204
|
+
const runHandlers = (instance, handlers, expressHandlers) => {
|
|
204
205
|
return Promise.all([
|
|
205
|
-
handlers && Promise.all(handlers.map((handler) => handler(
|
|
206
|
+
handlers && Promise.all(handlers.map((handler) => handler(instance))),
|
|
206
207
|
expressHandlers && Promise.all(expressHandlers.map((handler) => handler(expressApp))),
|
|
207
208
|
]);
|
|
208
209
|
};
|
|
@@ -213,73 +214,79 @@ const webAppInitCommand = ({ app, expressApp, logger, commandLineRunner, beforeI
|
|
|
213
214
|
instance: expressApp,
|
|
214
215
|
},
|
|
215
216
|
});
|
|
216
|
-
await
|
|
217
|
-
|
|
218
|
-
await app.register(fastifyCookie);
|
|
219
|
-
await app.register(fastifyFormBody, { bodyLimit: 2097152 }); // 2mb
|
|
220
|
-
await runHandlers(init, expressInit);
|
|
221
|
-
// force express to execute to update server's request and response instances
|
|
222
|
-
app.use((req, res, next) => {
|
|
223
|
-
next();
|
|
217
|
+
await app.register(async (instance) => {
|
|
218
|
+
await runHandlers(instance, beforeInit, expressBeforeInit);
|
|
224
219
|
});
|
|
225
|
-
app.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
useValue: request.raw,
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
provide: RESPONSE,
|
|
240
|
-
scope: Scope.REQUEST,
|
|
241
|
-
useValue: reply.raw,
|
|
242
|
-
},
|
|
243
|
-
// TODO: перевести использование на новые
|
|
244
|
-
// TODO: добавить для papi
|
|
245
|
-
{
|
|
246
|
-
provide: FASTIFY_REQUEST,
|
|
247
|
-
scope: Scope.REQUEST,
|
|
248
|
-
useValue: request,
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
provide: FASTIFY_RESPONSE,
|
|
252
|
-
scope: Scope.REQUEST,
|
|
253
|
-
useValue: reply,
|
|
254
|
-
},
|
|
255
|
-
]);
|
|
256
|
-
const responseManager = di.get(RESPONSE_MANAGER_TOKEN);
|
|
257
|
-
if (reply.sent) {
|
|
220
|
+
await app.register(async (instance) => {
|
|
221
|
+
await runHandlers(instance, limiterRequest, expressLimiterRequest);
|
|
222
|
+
await app.register(fastifyCookie);
|
|
223
|
+
await app.register(fastifyFormBody, { bodyLimit: 2097152 }); // 2mb
|
|
224
|
+
await runHandlers(instance, init, expressInit);
|
|
225
|
+
// force express to execute to update server's request and response instances
|
|
226
|
+
instance.use((req, res, next) => {
|
|
227
|
+
next();
|
|
228
|
+
});
|
|
229
|
+
instance.all('*', async (request, reply) => {
|
|
230
|
+
try {
|
|
258
231
|
log.debug({
|
|
259
|
-
event: '
|
|
260
|
-
message: '
|
|
232
|
+
event: 'start:request',
|
|
233
|
+
message: 'Клиент зашел на страницу',
|
|
261
234
|
url: request.url,
|
|
262
235
|
});
|
|
236
|
+
const di = await commandLineRunner.run('server', 'customer', [
|
|
237
|
+
{
|
|
238
|
+
provide: REQUEST,
|
|
239
|
+
scope: Scope.REQUEST,
|
|
240
|
+
useValue: request.raw,
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
provide: RESPONSE,
|
|
244
|
+
scope: Scope.REQUEST,
|
|
245
|
+
useValue: reply.raw,
|
|
246
|
+
},
|
|
247
|
+
// TODO: перевести использование на новые
|
|
248
|
+
// TODO: добавить для papi
|
|
249
|
+
{
|
|
250
|
+
provide: FASTIFY_REQUEST,
|
|
251
|
+
scope: Scope.REQUEST,
|
|
252
|
+
useValue: request,
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
provide: FASTIFY_RESPONSE,
|
|
256
|
+
scope: Scope.REQUEST,
|
|
257
|
+
useValue: reply,
|
|
258
|
+
},
|
|
259
|
+
]);
|
|
260
|
+
const responseManager = di.get(RESPONSE_MANAGER_TOKEN);
|
|
261
|
+
if (reply.sent) {
|
|
262
|
+
log.debug({
|
|
263
|
+
event: 'response-ended',
|
|
264
|
+
message: 'Response was already ended.',
|
|
265
|
+
url: request.url,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
reply
|
|
270
|
+
.header('content-type', 'text/html')
|
|
271
|
+
.headers(responseManager.getHeaders())
|
|
272
|
+
.status(responseManager.getStatus())
|
|
273
|
+
.send(responseManager.getBody());
|
|
274
|
+
}
|
|
263
275
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
catch (err) {
|
|
273
|
-
if (err.di) {
|
|
274
|
-
const responseManager = err.di.get(RESPONSE_MANAGER_TOKEN);
|
|
275
|
-
if (responseManager && !reply.sent) {
|
|
276
|
-
reply.headers(responseManager.getHeaders());
|
|
276
|
+
catch (err) {
|
|
277
|
+
if (err.di) {
|
|
278
|
+
const responseManager = err.di.get(RESPONSE_MANAGER_TOKEN);
|
|
279
|
+
if (responseManager && !reply.sent) {
|
|
280
|
+
reply.headers(responseManager.getHeaders());
|
|
281
|
+
}
|
|
277
282
|
}
|
|
283
|
+
throw err;
|
|
278
284
|
}
|
|
279
|
-
|
|
280
|
-
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
await app.register(async (instance) => {
|
|
288
|
+
await runHandlers(app, afterInit, expressAfterInit);
|
|
281
289
|
});
|
|
282
|
-
await runHandlers(afterInit, expressAfterInit);
|
|
283
290
|
await app.ready();
|
|
284
291
|
};
|
|
285
292
|
};
|
|
@@ -535,10 +542,10 @@ ServerStaticsModule = __decorate([
|
|
|
535
542
|
providers: [
|
|
536
543
|
provide({
|
|
537
544
|
provide: WEB_FASTIFY_APP_BEFORE_INIT_TOKEN,
|
|
538
|
-
useFactory: ({
|
|
545
|
+
useFactory: ({ options }) => {
|
|
539
546
|
const path = (options === null || options === void 0 ? void 0 : options.path) || 'public';
|
|
540
|
-
return () => {
|
|
541
|
-
|
|
547
|
+
return (instance) => {
|
|
548
|
+
instance.register(FastifyStatic, {
|
|
542
549
|
decorateReply: false,
|
|
543
550
|
prefix: `/${path}`,
|
|
544
551
|
root: resolve(process.cwd(), path),
|
|
@@ -551,7 +558,6 @@ ServerStaticsModule = __decorate([
|
|
|
551
558
|
};
|
|
552
559
|
},
|
|
553
560
|
deps: {
|
|
554
|
-
app: WEB_FASTIFY_APP_TOKEN,
|
|
555
561
|
options: {
|
|
556
562
|
token: SERVER_MODULE_STATICS_OPTIONS,
|
|
557
563
|
optional: true,
|
|
@@ -576,10 +582,10 @@ ServerGracefulShutdownModule = __decorate([
|
|
|
576
582
|
{
|
|
577
583
|
provide: WEB_FASTIFY_APP_BEFORE_INIT_TOKEN,
|
|
578
584
|
multi: true,
|
|
579
|
-
useFactory: ({
|
|
585
|
+
useFactory: ({ server, logger, commandLineRunner, livenessProbe, readinessProbe, }) => {
|
|
580
586
|
const log = logger('server');
|
|
581
|
-
return function serverListen() {
|
|
582
|
-
createTerminus(server,
|
|
587
|
+
return function serverListen(instance) {
|
|
588
|
+
createTerminus(server, instance, {
|
|
583
589
|
signal: 'SIGTERM',
|
|
584
590
|
timeout: GRACEFUL_SHUTDOWN_TIMEOUT,
|
|
585
591
|
logger: (msg, error) => {
|
|
@@ -619,7 +625,6 @@ ServerGracefulShutdownModule = __decorate([
|
|
|
619
625
|
};
|
|
620
626
|
},
|
|
621
627
|
deps: {
|
|
622
|
-
app: WEB_FASTIFY_APP_TOKEN,
|
|
623
628
|
server: SERVER_TOKEN,
|
|
624
629
|
logger: LOGGER_TOKEN,
|
|
625
630
|
commandLineRunner: COMMAND_LINE_RUNNER_TOKEN,
|
package/lib/server.js
CHANGED
|
@@ -141,10 +141,11 @@ const expressPlugin = (fastify, options, next) => {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
function onRegister(instance) {
|
|
144
|
+
var _a, _b;
|
|
144
145
|
const middlewares = instance[kMiddlewares].slice();
|
|
145
146
|
// eslint-disable-next-line no-param-reassign
|
|
146
147
|
instance[kMiddlewares] = [];
|
|
147
|
-
instance.decorate('express', express__default["default"]());
|
|
148
|
+
instance.decorate('express', (_b = (_a = options.express) === null || _a === void 0 ? void 0 : _a.instance) !== null && _b !== void 0 ? _b : express__default["default"]());
|
|
148
149
|
instance.express.disable('x-powered-by');
|
|
149
150
|
instance.decorate('use', use);
|
|
150
151
|
for (const middleware of middlewares) {
|
|
@@ -223,11 +224,11 @@ const webAppExpressFactory = ({ webApp }) => {
|
|
|
223
224
|
app.disable('x-powered-by');
|
|
224
225
|
return app;
|
|
225
226
|
};
|
|
226
|
-
const webAppInitCommand = ({ app, expressApp, logger, commandLineRunner, beforeInit, init, afterInit,
|
|
227
|
+
const webAppInitCommand = ({ app, expressApp, logger, commandLineRunner, beforeInit, limiterRequest, init, afterInit, expressBeforeInit, expressInit, expressAfterInit, expressLimiterRequest, beforeError, processError, afterError, }) => {
|
|
227
228
|
const log = logger('server:webapp');
|
|
228
|
-
const runHandlers = (handlers, expressHandlers) => {
|
|
229
|
+
const runHandlers = (instance, handlers, expressHandlers) => {
|
|
229
230
|
return Promise.all([
|
|
230
|
-
handlers && Promise.all(handlers.map((handler) => handler(
|
|
231
|
+
handlers && Promise.all(handlers.map((handler) => handler(instance))),
|
|
231
232
|
expressHandlers && Promise.all(expressHandlers.map((handler) => handler(expressApp))),
|
|
232
233
|
]);
|
|
233
234
|
};
|
|
@@ -238,73 +239,79 @@ const webAppInitCommand = ({ app, expressApp, logger, commandLineRunner, beforeI
|
|
|
238
239
|
instance: expressApp,
|
|
239
240
|
},
|
|
240
241
|
});
|
|
241
|
-
await
|
|
242
|
-
|
|
243
|
-
await app.register(fastifyCookie.fastifyCookie);
|
|
244
|
-
await app.register(fastifyFormBody__default["default"], { bodyLimit: 2097152 }); // 2mb
|
|
245
|
-
await runHandlers(init, expressInit);
|
|
246
|
-
// force express to execute to update server's request and response instances
|
|
247
|
-
app.use((req, res, next) => {
|
|
248
|
-
next();
|
|
242
|
+
await app.register(async (instance) => {
|
|
243
|
+
await runHandlers(instance, beforeInit, expressBeforeInit);
|
|
249
244
|
});
|
|
250
|
-
app.
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
useValue: request.raw,
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
provide: tokensCommon.RESPONSE,
|
|
265
|
-
scope: core.Scope.REQUEST,
|
|
266
|
-
useValue: reply.raw,
|
|
267
|
-
},
|
|
268
|
-
// TODO: перевести использование на новые
|
|
269
|
-
// TODO: добавить для papi
|
|
270
|
-
{
|
|
271
|
-
provide: tokensCommon.FASTIFY_REQUEST,
|
|
272
|
-
scope: core.Scope.REQUEST,
|
|
273
|
-
useValue: request,
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
provide: tokensCommon.FASTIFY_RESPONSE,
|
|
277
|
-
scope: core.Scope.REQUEST,
|
|
278
|
-
useValue: reply,
|
|
279
|
-
},
|
|
280
|
-
]);
|
|
281
|
-
const responseManager = di.get(tokensCommon.RESPONSE_MANAGER_TOKEN);
|
|
282
|
-
if (reply.sent) {
|
|
245
|
+
await app.register(async (instance) => {
|
|
246
|
+
await runHandlers(instance, limiterRequest, expressLimiterRequest);
|
|
247
|
+
await app.register(fastifyCookie.fastifyCookie);
|
|
248
|
+
await app.register(fastifyFormBody__default["default"], { bodyLimit: 2097152 }); // 2mb
|
|
249
|
+
await runHandlers(instance, init, expressInit);
|
|
250
|
+
// force express to execute to update server's request and response instances
|
|
251
|
+
instance.use((req, res, next) => {
|
|
252
|
+
next();
|
|
253
|
+
});
|
|
254
|
+
instance.all('*', async (request, reply) => {
|
|
255
|
+
try {
|
|
283
256
|
log.debug({
|
|
284
|
-
event: '
|
|
285
|
-
message: '
|
|
257
|
+
event: 'start:request',
|
|
258
|
+
message: 'Клиент зашел на страницу',
|
|
286
259
|
url: request.url,
|
|
287
260
|
});
|
|
261
|
+
const di = await commandLineRunner.run('server', 'customer', [
|
|
262
|
+
{
|
|
263
|
+
provide: tokensCommon.REQUEST,
|
|
264
|
+
scope: core.Scope.REQUEST,
|
|
265
|
+
useValue: request.raw,
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
provide: tokensCommon.RESPONSE,
|
|
269
|
+
scope: core.Scope.REQUEST,
|
|
270
|
+
useValue: reply.raw,
|
|
271
|
+
},
|
|
272
|
+
// TODO: перевести использование на новые
|
|
273
|
+
// TODO: добавить для papi
|
|
274
|
+
{
|
|
275
|
+
provide: tokensCommon.FASTIFY_REQUEST,
|
|
276
|
+
scope: core.Scope.REQUEST,
|
|
277
|
+
useValue: request,
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
provide: tokensCommon.FASTIFY_RESPONSE,
|
|
281
|
+
scope: core.Scope.REQUEST,
|
|
282
|
+
useValue: reply,
|
|
283
|
+
},
|
|
284
|
+
]);
|
|
285
|
+
const responseManager = di.get(tokensCommon.RESPONSE_MANAGER_TOKEN);
|
|
286
|
+
if (reply.sent) {
|
|
287
|
+
log.debug({
|
|
288
|
+
event: 'response-ended',
|
|
289
|
+
message: 'Response was already ended.',
|
|
290
|
+
url: request.url,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
reply
|
|
295
|
+
.header('content-type', 'text/html')
|
|
296
|
+
.headers(responseManager.getHeaders())
|
|
297
|
+
.status(responseManager.getStatus())
|
|
298
|
+
.send(responseManager.getBody());
|
|
299
|
+
}
|
|
288
300
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
.
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
catch (err) {
|
|
298
|
-
if (err.di) {
|
|
299
|
-
const responseManager = err.di.get(tokensCommon.RESPONSE_MANAGER_TOKEN);
|
|
300
|
-
if (responseManager && !reply.sent) {
|
|
301
|
-
reply.headers(responseManager.getHeaders());
|
|
301
|
+
catch (err) {
|
|
302
|
+
if (err.di) {
|
|
303
|
+
const responseManager = err.di.get(tokensCommon.RESPONSE_MANAGER_TOKEN);
|
|
304
|
+
if (responseManager && !reply.sent) {
|
|
305
|
+
reply.headers(responseManager.getHeaders());
|
|
306
|
+
}
|
|
302
307
|
}
|
|
308
|
+
throw err;
|
|
303
309
|
}
|
|
304
|
-
|
|
305
|
-
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
await app.register(async (instance) => {
|
|
313
|
+
await runHandlers(app, afterInit, expressAfterInit);
|
|
306
314
|
});
|
|
307
|
-
await runHandlers(afterInit, expressAfterInit);
|
|
308
315
|
await app.ready();
|
|
309
316
|
};
|
|
310
317
|
};
|
|
@@ -560,10 +567,10 @@ ServerStaticsModule = tslib.__decorate([
|
|
|
560
567
|
providers: [
|
|
561
568
|
core.provide({
|
|
562
569
|
provide: tokensServerPrivate.WEB_FASTIFY_APP_BEFORE_INIT_TOKEN,
|
|
563
|
-
useFactory: ({
|
|
570
|
+
useFactory: ({ options }) => {
|
|
564
571
|
const path$1 = (options === null || options === void 0 ? void 0 : options.path) || 'public';
|
|
565
|
-
return () => {
|
|
566
|
-
|
|
572
|
+
return (instance) => {
|
|
573
|
+
instance.register(FastifyStatic__default["default"], {
|
|
567
574
|
decorateReply: false,
|
|
568
575
|
prefix: `/${path$1}`,
|
|
569
576
|
root: path.resolve(process.cwd(), path$1),
|
|
@@ -576,7 +583,6 @@ ServerStaticsModule = tslib.__decorate([
|
|
|
576
583
|
};
|
|
577
584
|
},
|
|
578
585
|
deps: {
|
|
579
|
-
app: tokensServerPrivate.WEB_FASTIFY_APP_TOKEN,
|
|
580
586
|
options: {
|
|
581
587
|
token: tokensServer.SERVER_MODULE_STATICS_OPTIONS,
|
|
582
588
|
optional: true,
|
|
@@ -601,10 +607,10 @@ ServerGracefulShutdownModule = tslib.__decorate([
|
|
|
601
607
|
{
|
|
602
608
|
provide: tokensServerPrivate.WEB_FASTIFY_APP_BEFORE_INIT_TOKEN,
|
|
603
609
|
multi: true,
|
|
604
|
-
useFactory: ({
|
|
610
|
+
useFactory: ({ server, logger, commandLineRunner, livenessProbe, readinessProbe, }) => {
|
|
605
611
|
const log = logger('server');
|
|
606
|
-
return function serverListen() {
|
|
607
|
-
terminus.createTerminus(server,
|
|
612
|
+
return function serverListen(instance) {
|
|
613
|
+
terminus.createTerminus(server, instance, {
|
|
608
614
|
signal: 'SIGTERM',
|
|
609
615
|
timeout: GRACEFUL_SHUTDOWN_TIMEOUT,
|
|
610
616
|
logger: (msg, error) => {
|
|
@@ -644,7 +650,6 @@ ServerGracefulShutdownModule = tslib.__decorate([
|
|
|
644
650
|
};
|
|
645
651
|
},
|
|
646
652
|
deps: {
|
|
647
|
-
app: tokensServerPrivate.WEB_FASTIFY_APP_TOKEN,
|
|
648
653
|
server: tokensServer.SERVER_TOKEN,
|
|
649
654
|
logger: tokensCommon.LOGGER_TOKEN,
|
|
650
655
|
commandLineRunner: core.COMMAND_LINE_RUNNER_TOKEN,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-server",
|
|
3
|
-
"version": "1.94.
|
|
3
|
+
"version": "1.94.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@tinkoff/errors": "0.2.20",
|
|
23
23
|
"@tinkoff/monkeypatch": "1.3.3",
|
|
24
|
-
"@tinkoff/terminus": "0.0.
|
|
24
|
+
"@tinkoff/terminus": "0.0.2",
|
|
25
25
|
"@tinkoff/url": "0.7.37",
|
|
26
|
-
"@tramvai/module-cache-warmup": "1.94.
|
|
27
|
-
"@tramvai/module-metrics": "1.94.
|
|
28
|
-
"@tramvai/papi": "1.94.
|
|
29
|
-
"@tramvai/tokens-server": "1.94.
|
|
30
|
-
"@tramvai/tokens-server-private": "1.94.
|
|
26
|
+
"@tramvai/module-cache-warmup": "1.94.1",
|
|
27
|
+
"@tramvai/module-metrics": "1.94.1",
|
|
28
|
+
"@tramvai/papi": "1.94.1",
|
|
29
|
+
"@tramvai/tokens-server": "1.94.1",
|
|
30
|
+
"@tramvai/tokens-server-private": "1.94.1",
|
|
31
31
|
"compression": "^1.7.4",
|
|
32
32
|
"express": "^4.17.1",
|
|
33
33
|
"fastify": "^3.27.4",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@tinkoff/dippy": "0.7.39",
|
|
42
42
|
"@tinkoff/utils": "^2.1.2",
|
|
43
|
-
"@tramvai/cli": "1.94.
|
|
44
|
-
"@tramvai/core": "1.94.
|
|
45
|
-
"@tramvai/module-common": "1.94.
|
|
46
|
-
"@tramvai/module-environment": "1.94.
|
|
47
|
-
"@tramvai/tokens-common": "1.94.
|
|
43
|
+
"@tramvai/cli": "1.94.1",
|
|
44
|
+
"@tramvai/core": "1.94.1",
|
|
45
|
+
"@tramvai/module-common": "1.94.1",
|
|
46
|
+
"@tramvai/module-environment": "1.94.1",
|
|
47
|
+
"@tramvai/tokens-common": "1.94.1",
|
|
48
48
|
"tslib": "^2.0.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|