feat(events-backend,events-node): add a parser option to events by content type
Signed-off-by: Rogerio Angeliski <angeliski@hotmail.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2025 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.
|
||||
*/
|
||||
import { HttpBodyParser } from './body-parser';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface HttpBodyParserOptions {
|
||||
contentType: string;
|
||||
parser: HttpBodyParser;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2025 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.
|
||||
*/
|
||||
|
||||
import { Request } from 'express';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type HttpBodyParsed = {
|
||||
bodyParsed: any;
|
||||
bodyBuffer: Buffer;
|
||||
encoding: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type HttpBodyParser = (
|
||||
request: Request,
|
||||
topic: string,
|
||||
) => Promise<HttpBodyParsed>;
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2025 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.
|
||||
*/
|
||||
export * from './HttpBodyParser';
|
||||
@@ -15,4 +15,6 @@
|
||||
*/
|
||||
|
||||
export type { HttpPostIngressOptions } from './HttpPostIngressOptions';
|
||||
export type { HttpBodyParserOptions } from './HttpBodyParserOptions';
|
||||
export * from './validation';
|
||||
export * from './body-parser';
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
EventBroker,
|
||||
EventPublisher,
|
||||
EventSubscriber,
|
||||
HttpBodyParserOptions,
|
||||
HttpPostIngressOptions,
|
||||
} from '@backstage/plugin-events-node';
|
||||
|
||||
@@ -46,6 +47,8 @@ export interface EventsExtensionPoint {
|
||||
): void;
|
||||
|
||||
addHttpPostIngress(options: HttpPostIngressOptions): void;
|
||||
|
||||
addHttpPostBodyParser(options: HttpBodyParserOptions): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user