Skip to content

Commit fc46a44

Browse files
committed
extract type
1 parent 231054d commit fc46a44

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/services/search-service/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export const routes = (router: KoaRouter) => {
6060
* 500:
6161
* description: Internal server error.
6262
*/
63+
64+
type SearchResultResponseContent = z.infer<
65+
typeof schemas.SearchResultSchema
66+
>[]
67+
6368
router.get('(.*)/search', async (ctx) => {
6469
const metadata = generateRouteMetadata(ctx)
6570
const queryParams = schemas.SearchQueryParamsSchema.safeParse(ctx.query)
@@ -82,6 +87,7 @@ export const routes = (router: KoaRouter) => {
8287
ctx.status = 500
8388
return
8489
}
90+
8591
const mappedProperties = getProperties.data.map(
8692
(property): schemas.PropertySearchResult => ({
8793
id: property.id,
@@ -100,9 +106,10 @@ export const routes = (router: KoaRouter) => {
100106

101107
ctx.body = {
102108
...metadata,
103-
content: [...mappedProperties, ...mappedBuildings] satisfies z.infer<
104-
typeof schemas.SearchResultSchema
105-
>[],
109+
content: [
110+
...mappedProperties,
111+
...mappedBuildings,
112+
] satisfies SearchResultResponseContent,
106113
}
107114
})
108115
}

0 commit comments

Comments
 (0)