-
Notifications
You must be signed in to change notification settings - Fork 91
Feat/add clerk auth and premium ux #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,12 @@ | ||
| FROM node:lts-alpine AS build | ||
| FROM oven/bun:latest AS build | ||
|
|
||
| WORKDIR /app/ | ||
|
|
||
| COPY . . | ||
|
|
||
| RUN corepack enable && corepack prepare pnpm@latest --activate | ||
| RUN --mount=type=cache,target=/root/.bun/install/cache \ | ||
| bun install --frozen-lockfile && \ | ||
| bun run build | ||
|
|
||
| RUN --mount=type=cache,target=/root/.local/share/pnpm \ | ||
| pnpm install --prefer-offline && \ | ||
| pnpm build | ||
|
|
||
| CMD [ "pnpm", "start" ] | ||
| CMD [ "bun", "run", "start" ] | ||
| EXPOSE 3000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import { fromError } from "zod-validation-error"; | |
| import { createLogger } from "@/lib/logger"; | ||
| import { redis } from "@/lib/redis"; | ||
| import { compress, decompress } from "@/lib/redis-compression"; | ||
| import { getTextDirection } from "@/lib/rtl"; | ||
|
|
||
| const logger = createLogger('api:jina'); | ||
|
|
||
|
|
@@ -18,6 +19,8 @@ const CachedArticleSchema = z.object({ | |
| byline: z.string().optional().nullable(), | ||
| publishedTime: z.string().optional().nullable(), | ||
| htmlContent: z.string().optional(), // Not available for jina.ai source | ||
| lang: z.string().optional().nullable(), | ||
| dir: z.enum(['rtl', 'ltr']).optional().nullable(), | ||
| }); | ||
|
|
||
| /** | ||
|
|
@@ -65,8 +68,8 @@ export async function GET(request: NextRequest) { | |
| article: { | ||
| ...article, | ||
| byline: article.byline || "", | ||
| dir: "", | ||
| lang: "", | ||
| dir: article.dir || getTextDirection(article.lang, article.textContent), | ||
| lang: article.lang || "", | ||
| publishedTime: article.publishedTime || null, | ||
| htmlContent: article.content, // Use markdown-converted HTML as htmlContent | ||
| }, | ||
|
|
@@ -158,18 +161,22 @@ export async function POST(request: NextRequest) { | |
| ]); | ||
| }; | ||
|
|
||
| // Detect text direction for the incoming article | ||
| const articleDir = getTextDirection(null, article.textContent); | ||
| const articleWithDir = { ...article, dir: articleDir, lang: article.lang || null }; | ||
|
Comment on lines
+164
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Either add - const articleWithDir = { ...article, dir: articleDir, lang: article.lang || null };
+ const articleWithDir = { ...article, dir: articleDir, lang: null };#!/bin/bash
# Verify JinaCacheUpdateSchema definition
echo "=== JinaCacheUpdateSchema definition ==="
rg -n -A15 'JinaCacheUpdateSchema' types/api.ts🤖 Prompt for AI Agents |
||
|
|
||
| // Only update if new article is longer or doesn't exist | ||
| if (!validatedExisting || article.length > validatedExisting.length) { | ||
| await saveToCache(article); | ||
| logger.info({ hostname: new URL(url).hostname, length: article.length }, 'Jina cache updated'); | ||
| await saveToCache(articleWithDir); | ||
| logger.info({ hostname: new URL(url).hostname, length: article.length, dir: articleDir }, 'Jina cache updated'); | ||
|
|
||
| const response = ArticleResponseSchema.parse({ | ||
| source: "jina.ai", | ||
| cacheURL: `https://r.jina.ai/${url}`, | ||
| article: { | ||
| ...article, | ||
| ...articleWithDir, | ||
| byline: article.byline || "", | ||
| dir: "", | ||
| dir: articleDir, | ||
| lang: "", | ||
| publishedTime: article.publishedTime || null, | ||
| htmlContent: article.content, // Use markdown-converted HTML as htmlContent | ||
|
|
@@ -187,8 +194,8 @@ export async function POST(request: NextRequest) { | |
| article: { | ||
| ...validatedExisting, | ||
| byline: validatedExisting.byline || "", | ||
| dir: "", | ||
| lang: "", | ||
| dir: validatedExisting.dir || getTextDirection(validatedExisting.lang, validatedExisting.textContent), | ||
| lang: validatedExisting.lang || "", | ||
| publishedTime: validatedExisting.publishedTime || null, | ||
| htmlContent: validatedExisting.content, // Use markdown-converted HTML as htmlContent | ||
| }, | ||
|
|
@@ -200,14 +207,17 @@ export async function POST(request: NextRequest) { | |
| } catch (error) { | ||
| logger.warn({ error: error instanceof Error ? error.message : String(error) }, 'Jina cache update error'); | ||
|
|
||
| // Detect text direction for the article | ||
| const articleDir = getTextDirection(null, article.textContent); | ||
|
|
||
| // Return the article even if caching fails | ||
| const response = ArticleResponseSchema.parse({ | ||
| source: "jina.ai", | ||
| cacheURL: `https://r.jina.ai/${url}`, | ||
| article: { | ||
| ...article, | ||
| byline: article.byline || "", | ||
| dir: "", | ||
| dir: articleDir, | ||
| lang: "", | ||
| publishedTime: article.publishedTime || null, | ||
| htmlContent: article.content, // Use markdown-converted HTML as htmlContent | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: mrmps/SMRY
Length of output: 29677
🏁 Script executed:
Repository: mrmps/SMRY
Length of output: 5544
Response object inconsistency:
imagefield presence varies across paths.The response at line 617 includes
image: validatedArticle.image || null, but similar response constructions at lines 533-549 and 556-572 omit this field. WhileArticleSchemadefinesimageas optional, this inconsistency means clients will receive different response structures depending on which code path executes (cache hit, post-fetch validation, or error handler).Add the
imagefield to the response blocks at lines 533-549 and 556-572 for consistency.🤖 Prompt for AI Agents