chore(events): apply post-merge comments
Introduces a new interface `RequestDetails` to abstract `Request` providing access to request body and headers. **BREAKING:** Replace `request: Request` with `request: RequestDetails` at `RequestValidator`. **BREAKING:** Remove required field `router` at `HttpPostIngressEventPublisher.fromConfig` and replace it with `bind(router: Router)`. Additionally, the path prefix `/http` will be added inside `HttpPostIngressEventPublisher`. Relates-to: PR #13931 Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2022 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface RequestDetails {
|
||||
/**
|
||||
* Request body. JSON payloads have been parsed already.
|
||||
*/
|
||||
body: unknown;
|
||||
/**
|
||||
* Key-value pairs of header names and values. Header names are lower-cased.
|
||||
*/
|
||||
headers: Record<string, string | string[] | undefined>;
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Request } from 'express';
|
||||
import { RequestDetails } from './RequestDetails';
|
||||
import { RequestValidationContext } from './RequestValidationContext';
|
||||
|
||||
/**
|
||||
@@ -29,6 +29,6 @@ import { RequestValidationContext } from './RequestValidationContext';
|
||||
* @public
|
||||
*/
|
||||
export type RequestValidator = (
|
||||
request: Request,
|
||||
request: RequestDetails,
|
||||
context: RequestValidationContext,
|
||||
) => Promise<void>;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export type { RequestDetails } from './RequestDetails';
|
||||
export type { RequestRejectionDetails } from './RequestRejectionDetails';
|
||||
export type { RequestValidationContext } from './RequestValidationContext';
|
||||
export type { RequestValidator } from './RequestValidator';
|
||||
|
||||
Reference in New Issue
Block a user