fix: refactor search routes (#1529)

Refactor find endpoints to be consistent in terms of input and output.
This commit is contained in:
David Nguyen
2024-12-11 19:39:50 +09:00
committed by GitHub
parent 3d7b28a92b
commit 5df1a6602e
35 changed files with 171 additions and 184 deletions

View File

@ -74,20 +74,28 @@ import {
} from './schema';
export const teamRouter = router({
getTeams: authenticatedProcedure
// Internal endpoint for now.
getTeams: authenticatedProcedure.query(async ({ ctx }) => {
return await getTeams({ userId: ctx.user.id });
}),
findTeams: authenticatedProcedure
.meta({
openapi: {
method: 'GET',
path: '/team',
summary: 'Get teams',
description: 'Returns all teams that you are a member of',
summary: 'Find teams',
description: 'Find your teams based on a search criteria',
tags: ['Teams'],
},
})
.input(z.void())
.input(ZFindTeamsQuerySchema)
.output(z.unknown())
.query(async ({ ctx }) => {
return await getTeams({ userId: ctx.user.id });
.query(async ({ input, ctx }) => {
return await findTeams({
userId: ctx.user.id,
...input,
});
}),
getTeam: authenticatedProcedure
@ -327,14 +335,6 @@ export const teamRouter = router({
});
}),
// Todo: Refactor, seems to be a redundant endpoint.
findTeams: authenticatedProcedure.input(ZFindTeamsQuerySchema).query(async ({ input, ctx }) => {
return await findTeams({
userId: ctx.user.id,
...input,
});
}),
// Internal endpoint for now.
createTeamEmailVerification: authenticatedProcedure
// .meta({