improved contracts
This commit is contained in:
@@ -4,7 +4,7 @@ import type { Services } from '@morten-olsen/fluxcurrent-core/utils/services.ts'
|
||||
import { parseDSL } from '@morten-olsen/fluxcurrent-core/services/documents/documents.dsl.ts';
|
||||
import { DocumentsService } from '@morten-olsen/fluxcurrent-core/services/documents/documents.ts';
|
||||
import {
|
||||
documentSchema,
|
||||
documentSearchResultSchema,
|
||||
type DocumentUpsertEvent,
|
||||
} from '@morten-olsen/fluxcurrent-core/services/documents/documents.schemas.ts';
|
||||
import { filterDocument } from '@morten-olsen/fluxcurrent-core/services/documents/documents.filter.ts';
|
||||
@@ -18,7 +18,7 @@ const searchEndpoint: FastifyPluginAsyncZod<{ services: Services }> = async (fas
|
||||
query: z.string().optional(),
|
||||
}),
|
||||
response: {
|
||||
200: z.array(documentSchema),
|
||||
200: documentSearchResultSchema,
|
||||
},
|
||||
},
|
||||
handler: async (req, res) => {
|
||||
@@ -42,7 +42,7 @@ const searchEndpoint: FastifyPluginAsyncZod<{ services: Services }> = async (fas
|
||||
const documentsService = services.get(DocumentsService);
|
||||
res.sse({ event: 'init' });
|
||||
const documents = await documentsService.search(query);
|
||||
for (const document of documents) {
|
||||
for (const document of documents.documents) {
|
||||
res.sse({ event: 'upsert', data: JSON.stringify(document) });
|
||||
}
|
||||
const listener = (event: DocumentUpsertEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user