Skip to content

Commit

Permalink
fix: parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Feb 8, 2024
1 parent 008989a commit 1ddcebf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ export class Framework extends Hono {
path: string,
handler: (
context: FrameContext,
previousContext: FrameContext,
previousContext?: FrameContext | undefined,
) => FrameHandlerReturnType | Promise<FrameHandlerReturnType>,
) {
// Frame Route (implements GET & POST).
this.use(path, async (c) => {
const query = c.req.query()
const previousContext = deserializeJson<FrameContext>(
query.previousContext,
)
const previousContext =
query.previousContext && query.previousContext !== 'undefined'
? deserializeJson<FrameContext>(query.previousContext)
: undefined

const context = await getFrameContext(c)
const { intents } = await handler(context, previousContext)
Expand Down Expand Up @@ -98,9 +99,10 @@ export class Framework extends Hono {
this.get(`${toBaseUrl(path)}/image`, async (c) => {
const query = c.req.query()
const parsedContext = deserializeJson<FrameContext>(query.context)
const parsedPreviousContext = deserializeJson<FrameContext>(
query.previousContext,
)
const parsedPreviousContext =
query.previousContext && query.previousContext !== 'undefined'
? deserializeJson<FrameContext>(query.previousContext)
: undefined
const { image } = await handler(parsedContext, parsedPreviousContext)
return new ImageResponse(image)
})
Expand Down

0 comments on commit 1ddcebf

Please sign in to comment.