events-backend: fix schema and response shape

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-05-26 17:56:43 +02:00
parent f13bd3e987
commit 1154a730f6
4 changed files with 10 additions and 5 deletions
@@ -250,6 +250,7 @@ export const spec = {
'application/json': {
schema: {
type: 'object',
required: ['events'],
properties: {
events: {
type: 'array',
@@ -258,7 +259,6 @@ export const spec = {
},
},
},
required: ['results'],
},
},
},
@@ -164,13 +164,13 @@ paths:
application/json:
schema:
type: object
required:
- events
properties:
events:
type: array
items:
$ref: '#/components/schemas/Event'
required:
- results
'202':
description: No new events are available. Response will block until the client should try again.
default:
@@ -216,7 +216,12 @@ export async function createEventBusRouter(options: {
);
if (events.length > 0) {
res.json({ events });
res.json({
events: events.map(event => ({
topic: event.topic,
payload: event.eventPayload,
})),
});
} else {
res.status(202);
res.flushHeaders();
@@ -20,5 +20,5 @@
import { Event } from '../models/Event.model';
export interface GetSubscriptionEvents200Response {
events?: Array<Event>;
events: Array<Event>;
}