-
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.
Merge pull request #84 from casesandberg/feature/tags
Tags
- Loading branch information
Showing
28 changed files
with
1,028 additions
and
18 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
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,32 @@ | ||
import { NextResponse } from 'next/server' | ||
import type { SchemaResponse } from '@play-money/api-helpers' | ||
import { auth } from '@play-money/auth' | ||
import { getMarketTagsLLM } from '@play-money/markets/lib/getMarketTagsLLM' | ||
import schema from './schema' | ||
|
||
export const dynamic = 'force-dynamic' | ||
|
||
export async function POST(req: Request): Promise<SchemaResponse<typeof schema.post.responses>> { | ||
try { | ||
const body = (await req.json()) as unknown | ||
const { question } = schema.post.requestBody.parse(body) | ||
|
||
const session = await auth() | ||
if (!session?.user?.id) { | ||
return NextResponse.json({ | ||
tags: [], | ||
}) | ||
} | ||
|
||
const tags = await getMarketTagsLLM({ | ||
question, | ||
}) | ||
|
||
return NextResponse.json({ | ||
tags, | ||
}) | ||
} catch (error) { | ||
console.log(error) // eslint-disable-line no-console -- Log error for debugging | ||
return NextResponse.json({ error: 'Error processing request' }, { status: 500 }) | ||
} | ||
} |
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,15 @@ | ||
import { z } from 'zod' | ||
import { ServerErrorSchema, createSchema } from '@play-money/api-helpers' | ||
|
||
export default createSchema({ | ||
post: { | ||
requestBody: z.object({ question: z.string() }), | ||
responses: { | ||
200: z.object({ | ||
tags: z.array(z.string()), | ||
}), | ||
404: ServerErrorSchema, | ||
500: ServerErrorSchema, | ||
}, | ||
}, | ||
}) |
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,18 @@ | ||
import React from 'react' | ||
import { getMarkets } from '@play-money/api-helpers/client' | ||
import { MarketList } from '@play-money/markets/components/MarketList' | ||
|
||
export default async function AppQuestionsPage({ params }: { params: { tag: string } }) { | ||
const { markets } = await getMarkets({ tag: params.tag }) | ||
|
||
return ( | ||
<div className="mx-auto flex max-w-screen-lg flex-1 flex-col gap-8 md:flex-row"> | ||
<div className="w-full"> | ||
<div className="mb-2 text-2xl font-semibold">{params.tag}</div> | ||
<MarketList markets={markets} /> | ||
</div> | ||
|
||
<div className="space-y-8 md:w-80" /> | ||
</div> | ||
) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.