Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default defineNuxtConfig({
github: {
orgToken: '',
},
oauthJwkOne: process.env.OAUTH_JWK_ONE || undefined,
oauthJwkOne: process.env.TEST ? '' : process.env.OAUTH_JWK_ONE || undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify which env flags the repo actually uses for tests/CI,
# and whether `process.env.TEST` is the right source of truth.

set -eu

echo "== Test-related env flags in scripts and workflows =="
rg -n -C2 '\b(TEST|VITEST|NODE_ENV)\b' \
  --glob 'package.json' \
  --glob '.github/**/*.yml' \
  --glob '.github/**/*.yaml' \
  --glob '**/*.json' \
  --glob '**/*.yml' \
  --glob '**/*.yaml'

echo
echo "== Current uses of std-env test detection versus raw TEST checks =="
rg -n -C2 '\bisTest\b|\bprocess\.env\.TEST\b' \
  --glob '**/*.{ts,tsx,js,mjs,cjs}'

Repository: npmx-dev/npmx.dev

Length of output: 2502


Replace process.env.TEST with isTest for consistent test environment detection.

The repository's test scripts set NODE_ENV=test, not TEST=true. The code already imports and uses isTest from std-env at line 253 in the same file; it should be reused here instead of checking a raw environment variable that isn't explicitly configured. Using process.env.TEST creates inconsistency and risks disabling the JWK config in the wrong environment.

Suggested change
-    oauthJwkOne: process.env.TEST ? '' : process.env.OAUTH_JWK_ONE || undefined,
+    oauthJwkOne: isTest ? '' : process.env.OAUTH_JWK_ONE || undefined,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
oauthJwkOne: process.env.TEST ? '' : process.env.OAUTH_JWK_ONE || undefined,
oauthJwkOne: isTest ? '' : process.env.OAUTH_JWK_ONE || undefined,

// Upstash Redis for distributed OAuth token refresh locking in production
upstash: {
redisRestUrl: process.env.UPSTASH_KV_REST_API_URL || process.env.KV_REST_API_URL || '',
Expand Down
7 changes: 6 additions & 1 deletion server/api/atproto/bluesky-author-profiles.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AuthorSchema } from '#shared/schemas/blog'
import { Client } from '@atproto/lex'
import type { Author, ResolvedAuthor } from '#shared/schemas/blog'
import * as app from '#shared/types/lexicons/app'
import * as crypto from 'node:crypto'

export default defineCachedEventHandler(
async event => {
Expand Down Expand Up @@ -75,7 +76,11 @@ export default defineCachedEventHandler(
maxAge: CACHE_MAX_AGE_ONE_DAY,
getKey: event => {
const { authors } = getQuery(event)
return `author-profiles:${authors ?? 'npmx.dev'}`
if (!authors) {
return 'author-profiles:npmx.dev'
}
const key = crypto.createHash('sha256').update(JSON.stringify(authors)).digest('hex')
return `author-profiles:${key}`
},
},
)
Loading