@jaypie/express 1.2.27 → 1.2.29
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/cjs/index.cjs +28 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +29 -5
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/esm/src/index.d.ts +0 -13
- /package/dist/cjs/{src/adapter → adapter}/LambdaRequest.d.ts +0 -0
- /package/dist/cjs/{src/adapter → adapter}/LambdaResponseBuffered.d.ts +0 -0
- /package/dist/cjs/{src/adapter → adapter}/LambdaResponseStreaming.d.ts +0 -0
- /package/dist/cjs/{src/adapter → adapter}/__tests__/LambdaRequest.spec.d.ts +0 -0
- /package/dist/cjs/{src/adapter → adapter}/__tests__/LambdaResponseBuffered.spec.d.ts +0 -0
- /package/dist/cjs/{src/adapter → adapter}/__tests__/LambdaResponseStreaming.spec.d.ts +0 -0
- /package/dist/cjs/{src/adapter → adapter}/__tests__/debug-harness.d.ts +0 -0
- /package/dist/cjs/{src/adapter → adapter}/__tests__/integration.spec.d.ts +0 -0
- /package/dist/cjs/{src/adapter → adapter}/index.d.ts +0 -0
- /package/dist/cjs/{src/adapter → adapter}/types.d.ts +0 -0
- /package/dist/cjs/{src/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/cjs/{src/cors.helper.d.ts → cors.helper.d.ts} +0 -0
- /package/dist/cjs/{src/decorateResponse.helper.d.ts → decorateResponse.helper.d.ts} +0 -0
- /package/dist/cjs/{src/echo.handler.d.ts → echo.handler.d.ts} +0 -0
- /package/dist/cjs/{src/expressHandler.d.ts → expressHandler.d.ts} +0 -0
- /package/dist/cjs/{src/expressStreamHandler.d.ts → expressStreamHandler.d.ts} +0 -0
- /package/dist/cjs/{src/fabricApiResponse.d.ts → fabricApiResponse.d.ts} +0 -0
- /package/dist/cjs/{src/getCurrentInvokeUuid.adapter.d.ts → getCurrentInvokeUuid.adapter.d.ts} +0 -0
- /package/dist/cjs/{src/http.handler.d.ts → http.handler.d.ts} +0 -0
- /package/dist/cjs/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/cjs/{src/routes.d.ts → routes.d.ts} +0 -0
- /package/dist/cjs/{src/summarizeRequest.helper.d.ts → summarizeRequest.helper.d.ts} +0 -0
- /package/dist/cjs/{src/summarizeResponse.helper.d.ts → summarizeResponse.helper.d.ts} +0 -0
- /package/dist/esm/{src/adapter → adapter}/LambdaRequest.d.ts +0 -0
- /package/dist/esm/{src/adapter → adapter}/LambdaResponseBuffered.d.ts +0 -0
- /package/dist/esm/{src/adapter → adapter}/LambdaResponseStreaming.d.ts +0 -0
- /package/dist/esm/{src/adapter → adapter}/__tests__/LambdaRequest.spec.d.ts +0 -0
- /package/dist/esm/{src/adapter → adapter}/__tests__/LambdaResponseBuffered.spec.d.ts +0 -0
- /package/dist/esm/{src/adapter → adapter}/__tests__/LambdaResponseStreaming.spec.d.ts +0 -0
- /package/dist/esm/{src/adapter → adapter}/__tests__/debug-harness.d.ts +0 -0
- /package/dist/esm/{src/adapter → adapter}/__tests__/integration.spec.d.ts +0 -0
- /package/dist/esm/{src/adapter → adapter}/index.d.ts +0 -0
- /package/dist/esm/{src/adapter → adapter}/types.d.ts +0 -0
- /package/dist/esm/{src/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/esm/{src/cors.helper.d.ts → cors.helper.d.ts} +0 -0
- /package/dist/esm/{src/decorateResponse.helper.d.ts → decorateResponse.helper.d.ts} +0 -0
- /package/dist/esm/{src/echo.handler.d.ts → echo.handler.d.ts} +0 -0
- /package/dist/esm/{src/expressHandler.d.ts → expressHandler.d.ts} +0 -0
- /package/dist/esm/{src/expressStreamHandler.d.ts → expressStreamHandler.d.ts} +0 -0
- /package/dist/esm/{src/fabricApiResponse.d.ts → fabricApiResponse.d.ts} +0 -0
- /package/dist/esm/{src/getCurrentInvokeUuid.adapter.d.ts → getCurrentInvokeUuid.adapter.d.ts} +0 -0
- /package/dist/esm/{src/http.handler.d.ts → http.handler.d.ts} +0 -0
- /package/dist/esm/{src/routes.d.ts → routes.d.ts} +0 -0
- /package/dist/esm/{src/summarizeRequest.helper.d.ts → summarizeRequest.helper.d.ts} +0 -0
- /package/dist/esm/{src/summarizeResponse.helper.d.ts → summarizeResponse.helper.d.ts} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ServerResponse } from 'node:http';
|
|
|
4
4
|
import { CorsError, BadRequestError, UnhandledError, GatewayTimeoutError, UnavailableError, BadGatewayError, InternalError, TeapotError, GoneError, MethodNotAllowedError, NotFoundError, ForbiddenError, UnauthorizedError, NotImplementedError } from '@jaypie/errors';
|
|
5
5
|
import { force, envBoolean, JAYPIE, HTTP, getHeaderFrom, jaypieHandler } from '@jaypie/kit';
|
|
6
6
|
import expressCors from 'cors';
|
|
7
|
-
import { loadEnvSecrets, getContentTypeForFormat, formatStreamError } from '@jaypie/aws';
|
|
7
|
+
import { loadEnvVariables, loadEnvSecrets, getContentTypeForFormat, formatStreamError } from '@jaypie/aws';
|
|
8
8
|
import { log, redactAuth } from '@jaypie/logger';
|
|
9
9
|
|
|
10
10
|
//
|
|
@@ -1786,6 +1786,9 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
1786
1786
|
//
|
|
1787
1787
|
// Setup
|
|
1788
1788
|
//
|
|
1789
|
+
// Start the variables fetch at cold start; request setup awaits the cached
|
|
1790
|
+
// promise. No-op without the pointer.
|
|
1791
|
+
void loadEnvVariables().catch(() => { });
|
|
1789
1792
|
let jaypieFunction;
|
|
1790
1793
|
return async (req, res, ...params) => {
|
|
1791
1794
|
// * This is the first line of code that runs when a request is received
|
|
@@ -1876,6 +1879,11 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
1876
1879
|
//
|
|
1877
1880
|
// Build a request-local setup list to avoid mutating the shared array
|
|
1878
1881
|
const requestSetup = [];
|
|
1882
|
+
// Hydrate non-secret variables first so everything after, including Datadog
|
|
1883
|
+
// and secrets, can be configured from the bundle. No-op without the pointer.
|
|
1884
|
+
requestSetup.push(async () => {
|
|
1885
|
+
await loadEnvVariables();
|
|
1886
|
+
});
|
|
1879
1887
|
// Load the Datadog LLM Observability API key into the environment when enabled
|
|
1880
1888
|
requestSetup.push(async () => {
|
|
1881
1889
|
await loadDatadogApiKey();
|
|
@@ -2065,14 +2073,18 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2065
2073
|
const contentLengthHeader = headers["content-length"];
|
|
2066
2074
|
const contentLength = contentLengthHeader ? Number(contentLengthHeader) : 0;
|
|
2067
2075
|
// Add request data to session report
|
|
2068
|
-
|
|
2076
|
+
const reportData = {
|
|
2069
2077
|
method: req.method,
|
|
2070
2078
|
path,
|
|
2071
2079
|
query,
|
|
2072
2080
|
contentType,
|
|
2073
2081
|
contentLength,
|
|
2074
2082
|
status: String(res.statusCode),
|
|
2075
|
-
}
|
|
2083
|
+
};
|
|
2084
|
+
if (req.params && Object.keys(req.params).length > 0) {
|
|
2085
|
+
reportData.parameters = { ...req.params };
|
|
2086
|
+
}
|
|
2087
|
+
logger$1.report(reportData);
|
|
2076
2088
|
// Submit metric if Datadog is configured
|
|
2077
2089
|
if (hasDatadogEnv()) {
|
|
2078
2090
|
let metricPrefix = "project";
|
|
@@ -2191,6 +2203,9 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2191
2203
|
//
|
|
2192
2204
|
// Setup
|
|
2193
2205
|
//
|
|
2206
|
+
// Start the variables fetch at cold start; request setup awaits the cached
|
|
2207
|
+
// promise. No-op without the pointer.
|
|
2208
|
+
void loadEnvVariables().catch(() => { });
|
|
2194
2209
|
let jaypieFunction;
|
|
2195
2210
|
return async (req, res, ...params) => {
|
|
2196
2211
|
const extReq = req;
|
|
@@ -2255,6 +2270,11 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2255
2270
|
//
|
|
2256
2271
|
// Build a request-local setup list to avoid mutating the shared array
|
|
2257
2272
|
const requestSetup = [];
|
|
2273
|
+
// Hydrate non-secret variables before secrets so both can be configured
|
|
2274
|
+
// from the bundle. No-op without the pointer.
|
|
2275
|
+
requestSetup.push(async () => {
|
|
2276
|
+
await loadEnvVariables();
|
|
2277
|
+
});
|
|
2258
2278
|
// Load secrets into process.env if configured
|
|
2259
2279
|
if (secrets && secrets.length > 0) {
|
|
2260
2280
|
const secretsToLoad = secrets;
|
|
@@ -2353,11 +2373,15 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2353
2373
|
}
|
|
2354
2374
|
path = path.replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, ":id");
|
|
2355
2375
|
// Add request data to session report
|
|
2356
|
-
|
|
2376
|
+
const reportData = {
|
|
2357
2377
|
method: req.method,
|
|
2358
2378
|
path,
|
|
2359
2379
|
status: String(res.statusCode),
|
|
2360
|
-
}
|
|
2380
|
+
};
|
|
2381
|
+
if (req.params && Object.keys(req.params).length > 0) {
|
|
2382
|
+
reportData.parameters = { ...req.params };
|
|
2383
|
+
}
|
|
2384
|
+
logger.report(reportData);
|
|
2361
2385
|
// Submit metric if Datadog is configured
|
|
2362
2386
|
if (hasDatadogEnv()) {
|
|
2363
2387
|
let metricPrefix = "project";
|