Skip to content

Conversation

thisismyamazingusername
Copy link

@thisismyamazingusername thisismyamazingusername commented Oct 9, 2025

  • update env for local dev
  • update readme
  • update gitignore

Summary by CodeRabbit

  • Documentation

    • Clarified setup: note to install pnpm.
    • Updated Notion integration instructions (terminology, search by integration name, revised connection and capabilities steps).
  • Chores

    • Added environment variable loader dependency to support local development.
    • Ignored a build-regenerated cache file to keep repositories clean.
    • Trimmed unused entries from the example environment file.

Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Removed Notion-related env entries from .env.example. Added posts-cache.json to .gitignore. Updated README setup wording and pnpm note. Added dotenv dependency. In src/lib/notion.ts, conditionally load env with dotenv for local dev, set explicit Notion API version, and added a ts-ignore in fetchPublishedPosts.

Changes

Cohort / File(s) Summary
Environment templates
./.env.example
Removed NOTION_TOKEN=, NOTION_DATABASE_ID=, and NEXT_PUBLIC_SITE_URL=https://example.com.
VCS ignore rules
./.gitignore
Ignored posts-cache.json with a comment noting it is regenerated on each build.
Docs and setup
./README.md
Added pnpm download note; refined Notion integration instructions (term “Internal Integration Secret”, guidance on naming/searching, and connection step wording).
Tooling and deps
./package.json
Added dotenv dependency; shuffled devDependencies (removed and re-added tw-animate-css with same version).
Notion client and env loading
./src/lib/notion.ts
Conditional dotenv loading for local dev (skips on Vercel or if token present); initialized Notion Client with notionVersion: "2022-06-28"; added // @ts-ignore before query; removed stray local path import.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as App Startup
  participant Env as dotenv (local)
  participant Proc as process.env
  participant Notion as Notion Client
  participant API as Notion API

  App->>Proc: Check VERCEL / NOTION_TOKEN
  alt Local dev and NOTION_TOKEN missing
    App->>Env: config({ path: .env.local/.env })
    Env-->>Proc: Populate env vars
  else Hosted or token present
    App-->>Proc: Skip dotenv
  end

  App->>Notion: new Client({ auth: NOTION_TOKEN, notionVersion: "2022-06-28" })
  App->>Notion: fetchPublishedPosts()
  Note right of App: ts-ignore applied for query typing
  Notion->>API: query database for published posts
  API-->>Notion: Results
  Notion-->>App: Posts
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I thump my paws at envs that hide,
A dotenv burrow by my side.
With Notion’s version set just right,
I cache my carrots out of sight.
Git ignores my nibble trail—
Docs updated, tails a-flail. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title “updates for new forkers” is too generic and does not clearly convey the primary changes, which include modifying the environment example, .gitignore, README instructions, and adding dotenv support; it hints at the audience but fails to summarize the specific updates. Please choose a more descriptive title that highlights the key changes, for example “Update .env.example, .gitignore, and README for smoother local setup” so readers can immediately grasp the scope of the PR.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/lib/notion.ts (2)

1-6: Consider simplifying the dotenv loading pattern.

The conditional environment loading works but could be simplified. The explicit path resolution with path.resolve(process.cwd(), '.env.local') is redundant since dotenv naturally looks for .env.local in the current directory when using the default path option.

Consider this simpler approach:

-import dotenv from 'dotenv';
-import path from 'path';
-
-if (!process.env.VERCEL && !process.env.NOTION_TOKEN) {
-  dotenv.config({ path: path.resolve(process.cwd(), '.env.local') });
-}
+import dotenv from 'dotenv';
+
+if (!process.env.VERCEL && !process.env.NOTION_TOKEN) {
+  dotenv.config({ path: '.env.local' });
+}

Alternatively, omit the path entirely since dotenv automatically searches for .env.local:

-import dotenv from 'dotenv';
-import path from 'path';
-
-if (!process.env.VERCEL && !process.env.NOTION_TOKEN) {
-  dotenv.config({ path: path.resolve(process.cwd(), '.env.local') });
-}
+import dotenv from 'dotenv';
+
+if (!process.env.VERCEL && !process.env.NOTION_TOKEN) {
+  dotenv.config();
+}

Based on learnings.


13-16: Update or confirm Notion API version
Bump notionVersion in src/lib/notion.ts to "2025-09-03" or explicitly confirm retaining "2022-06-28"; if upgrading, adjust for reorganized /v1/data_sources endpoints per Notion’s upgrade guide.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 556bea6 and cf96b54.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • .env.example (0 hunks)
  • .gitignore (1 hunks)
  • README.md (2 hunks)
  • package.json (2 hunks)
  • src/lib/notion.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • .env.example
🔇 Additional comments (5)
.gitignore (1)

16-18: LGTM!

The addition of posts-cache.json to .gitignore is appropriate. Cache files should not be committed to version control, and the comment clearly explains that it's regenerated on each build.

package.json (2)

33-33: LGTM!

The addition of dotenv as a runtime dependency correctly supports the local development environment loading implemented in src/lib/notion.ts. Based on learnings, version 17.2.3 is the latest stable release.


57-57: Minor observation: tw-animate-css reordering.

This dependency appears to have been removed and re-added (same version), which is a cosmetic no-op. This doesn't affect functionality.

README.md (2)

22-22: LGTM!

The note about downloading pnpm is helpful for new users who may not have it installed.


39-39: LGTM!

The documentation updates improve clarity and align with current Notion API terminology:

  • Updated integration naming guidance for easier searching
  • "Internal Integration Secret" is more precise than "token"
  • "Enter your integration name" is clearer than the previous instruction

Also applies to: 43-43, 49-49


export async function fetchPublishedPosts() {
// This function is now intended to be used only by the caching script.
// @ts-ignore - bypass TypeScript error with v4 SDK types
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove the @ts-ignore directive and fix the underlying type issue.

Using @ts-ignore suppresses TypeScript's type checking, which defeats the purpose of using TypeScript and can hide legitimate type errors. The comment mentions "v4 SDK types" but doesn't explain why bypassing types is safe or necessary.

Instead of suppressing the error, investigate and resolve the underlying type mismatch. Possible solutions:

  1. Cast the response appropriately if you're confident about the runtime types
  2. Update the SDK if there's a version mismatch
  3. Define proper types that match the actual API response

If the SDK types are genuinely incorrect, consider:

  • Opening an issue with the SDK maintainers
  • Adding a detailed comment explaining the type mismatch and why the workaround is safe
  • Using a type assertion instead of @ts-ignore to maintain some type safety

Example with type assertion:

const posts = await notion.databases.query({
  database_id: process.env.NOTION_DATABASE_ID!,
  filter: {
    and: [
      {
        property: "Status",
        status: {
          equals: "Published",
        },
      },
    ],
  },
  sorts: [
    {
      property: "Published Date",
      direction: "descending",
    },
  ],
}) as any; // More explicit about intentional type bypass
🤖 Prompt for AI Agents
In src/lib/notion.ts around line 63, remove the `// @ts-ignore` and fix the
underlying type mismatch by either importing and using the correct Notion SDK
types (or updating the SDK if versions are mismatched), or replace the ignore
with a narrow type assertion that matches the actual response shape (define an
interface for the expected query result and cast the response to that
interface), ensuring you keep type safety and add a short comment if the
assertion is intentional; if the SDK types are truly wrong, note that in a TODO
and consider filing an upstream issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant