quidproquo-webserver 0.0.45 → 0.0.47
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.
|
@@ -2,7 +2,7 @@ import { QPQConfig } from 'quidproquo-core';
|
|
|
2
2
|
import { RouteQPQWebServerConfigSetting } from './config/settings/route';
|
|
3
3
|
import { SeoQPQWebServerConfigSetting } from './config/settings/seo';
|
|
4
4
|
import { OpenApiQPQWebServerConfigSetting } from './config/settings/openApi';
|
|
5
|
-
import { HttpEventHeaders } from './types/HTTPEvent';
|
|
5
|
+
import { HttpEventHeaders, HTTPEventParams, HTTPEventResponse } from './types/HTTPEvent';
|
|
6
6
|
import { RouteOptions } from './config/settings/route';
|
|
7
7
|
export declare const getAllRoutes: (configs: QPQConfig) => RouteQPQWebServerConfigSetting[];
|
|
8
8
|
export declare const getAllSeo: (configs: QPQConfig) => SeoQPQWebServerConfigSetting[];
|
|
@@ -14,3 +14,5 @@ export declare const getFeatureDomainName: (configs: QPQConfig) => string;
|
|
|
14
14
|
export declare const getHeaderValue: (header: string, headers: HttpEventHeaders) => string | null;
|
|
15
15
|
export declare const getAllowedOrigins: (configs: QPQConfig, route: RouteOptions) => string[];
|
|
16
16
|
export declare const getCorsHeaders: (configs: QPQConfig, route: RouteOptions, reqHeaders: HttpEventHeaders) => HttpEventHeaders;
|
|
17
|
+
export declare const fromJsonEventRequest: <T>(httpJsonEvent: HTTPEventParams) => T;
|
|
18
|
+
export declare const toJsonEventResponse: (item: any, status?: number) => HTTPEventResponse;
|
package/lib/qpqWebServerUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCorsHeaders = exports.getAllowedOrigins = exports.getHeaderValue = exports.getFeatureDomainName = exports.getDomainName = exports.getAllSrcEntries = exports.getAllOpenApiSpecs = exports.getDeployRegion = exports.getAllSeo = exports.getAllRoutes = void 0;
|
|
3
|
+
exports.toJsonEventResponse = exports.fromJsonEventRequest = exports.getCorsHeaders = exports.getAllowedOrigins = exports.getHeaderValue = exports.getFeatureDomainName = exports.getDomainName = exports.getAllSrcEntries = exports.getAllOpenApiSpecs = exports.getDeployRegion = exports.getAllSeo = exports.getAllRoutes = void 0;
|
|
4
4
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
5
5
|
const QPQConfig_1 = require("./config/QPQConfig");
|
|
6
6
|
const qpqCoreUtils_1 = require("quidproquo-core/lib/qpqCoreUtils");
|
|
@@ -81,3 +81,21 @@ const getCorsHeaders = (configs, route, reqHeaders) => {
|
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
83
|
exports.getCorsHeaders = getCorsHeaders;
|
|
84
|
+
const fromJsonEventRequest = (httpJsonEvent) => {
|
|
85
|
+
const item = JSON.parse(httpJsonEvent.isBase64Encoded
|
|
86
|
+
? Buffer.from(httpJsonEvent.body, 'base64').toString()
|
|
87
|
+
: httpJsonEvent.body);
|
|
88
|
+
return item;
|
|
89
|
+
};
|
|
90
|
+
exports.fromJsonEventRequest = fromJsonEventRequest;
|
|
91
|
+
const toJsonEventResponse = (item, status = 200) => {
|
|
92
|
+
return {
|
|
93
|
+
status,
|
|
94
|
+
body: JSON.stringify(item),
|
|
95
|
+
isBase64Encoded: false,
|
|
96
|
+
headers: {
|
|
97
|
+
'content-type': 'application/json',
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
exports.toJsonEventResponse = toJsonEventResponse;
|
package/lib/types/HTTPEvent.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { HTTPMethod } from 'quidproquo-core';
|
|
|
2
2
|
export interface HttpEventHeaders {
|
|
3
3
|
[key: string]: undefined | string;
|
|
4
4
|
}
|
|
5
|
-
export interface HTTPEventParams<T> {
|
|
5
|
+
export interface HTTPEventParams<T = string> {
|
|
6
6
|
path: string;
|
|
7
7
|
query: {
|
|
8
8
|
[key: string]: undefined | string | string[];
|
|
@@ -12,4 +12,11 @@ export interface HTTPEventParams<T> {
|
|
|
12
12
|
method: HTTPMethod;
|
|
13
13
|
correlation: string;
|
|
14
14
|
sourceIp: string;
|
|
15
|
+
isBase64Encoded: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface HTTPEventResponse<T = string> {
|
|
18
|
+
status: number;
|
|
19
|
+
body?: T;
|
|
20
|
+
headers?: HttpEventHeaders;
|
|
21
|
+
isBase64Encoded: boolean;
|
|
15
22
|
}
|
package/lib/types/SEOEvent.d.ts
CHANGED
|
@@ -12,10 +12,12 @@ export interface SeoEventParams<T = null> {
|
|
|
12
12
|
method: HTTPMethod;
|
|
13
13
|
correlation: string;
|
|
14
14
|
sourceIp: string;
|
|
15
|
+
domain: string;
|
|
15
16
|
}
|
|
16
17
|
export interface SeoEventResponse {
|
|
17
18
|
fallbackToCDN?: boolean;
|
|
18
19
|
status: number;
|
|
19
20
|
body?: string;
|
|
20
21
|
headers?: SeoEventHeaders;
|
|
22
|
+
bodyEncoding?: 'binary' | 'base64';
|
|
21
23
|
}
|