Next.js Discord

Discord Forum

Accessing the codebase dynamically after deployed

Unanswered
Japanese flying squid posted this in #help-forum
Open in Discord
Japanese flying squidOP
Hey folks, I am working on a Drag and drop React/TypeScript builder and testing it within Next.js. I am trying to build a open source library that lets people manipulate their codebase, dynamically.

There is a search functionality which lets users to type in and find functions within their codebase/repository. This search works well within local dev environment, but does not work when deployed. I suspect this is because it is compiled, built and served that way when deployed, and codebase does not exist anymore. How can I overcome this?

I attached a screenshot from the dev environment where it works. Also, here is the code for the search endpoint. It is a simple endpoint that is hit within Next.js app and calls searcher.search function to access the codebase.

import { initializeSearcher } from "@repo/parser";
import { NextResponse } from "next/server";

const searcher = initializeSearcher(process.cwd());

export async function GET(request: Request) {
  const { searchParams } = new URL(request.url);
  const query = searchParams.get("q");

  if (!query) {
    return NextResponse.json(
      { error: "Query parameter is required" },
      { status: 400 }
    );
  }

  const results = await searcher.search(query);
  return NextResponse.json(results);
}


initializeSearcher code is more complex and long, so I am not posting it directly here but you can find the content here:

https://github.com/ozhanefemeral/visual-ts/blob/cf7db8bcec70645f0d897144ffeef937de7f3a4e/packages/parser/src/utils/codebase-searcher.ts

0 Replies