Merge pull request #28834 from angeliski/add-body-parser-event

feat(events-backend,events-node) add a parser option to events ingress
This commit is contained in:
Patrik Oldsberg
2025-03-11 11:05:52 +01:00
committed by GitHub
18 changed files with 446 additions and 47 deletions
+4
View File
@@ -55,7 +55,11 @@
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/errors": "workspace:^",
"@backstage/types": "workspace:^",
"@types/content-type": "^1.1.8",
"@types/express": "^4.17.6",
"content-type": "^1.0.5",
"cross-fetch": "^4.0.0",
"express": "^4.17.1",
"uri-template": "^2.0.0"
},
"devDependencies": {
+3
View File
@@ -7,10 +7,13 @@ import { EventBroker } from '@backstage/plugin-events-node';
import { EventPublisher } from '@backstage/plugin-events-node';
import { EventSubscriber } from '@backstage/plugin-events-node';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { HttpBodyParserOptions } from '@backstage/plugin-events-node';
import { HttpPostIngressOptions } from '@backstage/plugin-events-node';
// @alpha (undocumented)
export interface EventsExtensionPoint {
// (undocumented)
addHttpPostBodyParser(options: HttpBodyParserOptions): void;
// (undocumented)
addHttpPostIngress(options: HttpPostIngressOptions): void;
// @deprecated (undocumented)
+24
View File
@@ -7,6 +7,8 @@ import { AuthService } from '@backstage/backend-plugin-api';
import { DiscoveryService } from '@backstage/backend-plugin-api';
import { LifecycleService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { ParsedMediaType } from 'content-type';
import { Request as Request_2 } from 'express';
import { RootConfigService } from '@backstage/backend-plugin-api';
import { ServiceFactory } from '@backstage/backend-plugin-api';
import { ServiceRef } from '@backstage/backend-plugin-api';
@@ -109,6 +111,28 @@ export interface EventSubscriber {
supportsEventTopics(): string[];
}
// @public (undocumented)
export type HttpBodyParsed = {
bodyParsed: any;
bodyBuffer: Buffer;
encoding: string;
};
// @public (undocumented)
export type HttpBodyParser = (
request: Request_2,
parsedMediaType: ParsedMediaType,
topic: string,
) => Promise<HttpBodyParsed>;
// @public (undocumented)
export interface HttpBodyParserOptions {
// (undocumented)
contentType: string;
// (undocumented)
parser: HttpBodyParser;
}
// @public (undocumented)
export interface HttpPostIngressOptions {
// (undocumented)
@@ -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,35 @@
/*
* 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';
import { ParsedMediaType } from 'content-type';
/**
* @public
*/
export type HttpBodyParsed = {
bodyParsed: any;
bodyBuffer: Buffer;
encoding: string;
};
/**
* @public
*/
export type HttpBodyParser = (
request: Request,
parsedMediaType: ParsedMediaType,
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';
+3
View File
@@ -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;
}
/**