-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate to Anteater API (#505)
- Loading branch information
Showing
47 changed files
with
541 additions
and
788 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
types/src/generated/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
@module SearchRoute | ||
*/ | ||
|
||
import { z } from 'zod'; | ||
import { publicProcedure, router } from '../helpers/trpc'; | ||
import { SearchAAPIResponse } from '@peterportal/types'; | ||
import { ANTEATER_API_REQUEST_HEADERS } from '../helpers/headers'; | ||
|
||
const searchRouter = router({ | ||
/** | ||
* Anteater API proxy for fuzzy search | ||
*/ | ||
get: publicProcedure | ||
.input( | ||
z.object({ | ||
query: z.string(), | ||
skip: z | ||
.number() | ||
.int() | ||
.transform((x) => x.toString()), | ||
take: z | ||
.number() | ||
.int() | ||
.transform((x) => x.toString()), | ||
resultType: z.union([z.literal('course'), z.literal('instructor')]), | ||
}), | ||
) | ||
.query(async ({ input }) => { | ||
const r = fetch(`${process.env.PUBLIC_API_URL}search?${new URLSearchParams(input).toString()}`, { | ||
headers: ANTEATER_API_REQUEST_HEADERS, | ||
}); | ||
|
||
return r.then((response) => response.json()).then((data) => data.data as SearchAAPIResponse); | ||
}), | ||
}); | ||
|
||
export default searchRouter; |
Oops, something went wrong.