Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ node_modules
# production
packages/**/build
packages/**/lib
!packages/fern-dashboard/src/lib
packages/**/dist
packages/**/tsconfig*tsbuildinfo
packages/**/out
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


lib
!packages/fern-dashboard/src/lib
build
dist
.yarn
Expand Down
1 change: 0 additions & 1 deletion .vercelignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
packages/**/dist
packages/**/build
packages/**/lib
!packages/fern-dashboard/src/lib
servers/**
clis/**
docker/**
4 changes: 2 additions & 2 deletions packages/fern-dashboard/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"utils": "@/utils/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"lib": "@/utils",
"hooks": "@/hooks"
},
"iconLibrary": "lucide"
Expand Down
12 changes: 0 additions & 12 deletions packages/fern-dashboard/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
/* eslint-disable turbo/no-undeclared-env-vars */
import type { NextConfig } from "next";

const APP_BASE_URL =
process.env.VERCEL_ENV === "preview"
? `https://${process.env.VERCEL_BRANCH_URL}`
: process.env.NEXT_PUBLIC_APP_BASE_URL;

const nextConfig: NextConfig = {
transpilePackages: [
/**
Expand All @@ -29,13 +24,6 @@ const nextConfig: NextConfig = {
},
],
},
env: {
// need this to be NEXT_PUBLIC_ so it's accessible in auth0.ts
NEXT_PUBLIC_APP_BASE_URL: APP_BASE_URL,

// Auth0 expects APP_BASE_URL to exist
APP_BASE_URL,
},
webpack: (webpackConfig) => {
webpackConfig.externals.push("sharp");
return webpackConfig;
Expand Down
4 changes: 3 additions & 1 deletion packages/fern-dashboard/src/app/actions/auth0.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GetOrganizations200ResponseOneOfInner, ManagementClient } from "auth0";
import jwt from "jsonwebtoken";

import { auth0 } from "@/lib/auth0";
import { getAuth0Client } from "@/utils/auth0";

import { AsyncCache } from "./AsyncCache";
import { Auth0OrgName } from "./types";
Expand Down Expand Up @@ -34,6 +34,7 @@ export function getAuth0ManagementClient() {
}

export async function getCurrentSession() {
const auth0 = await getAuth0Client();
const session = await auth0.getSession();
if (session == null) {
throw new Error("Not authenticated");
Expand Down Expand Up @@ -62,6 +63,7 @@ export async function getCurrentSession() {
}

export async function getCurrentOrgId() {
const auth0 = await getAuth0Client();
const session = await auth0.getSession();

if (session?.user.org_id == null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/fern-dashboard/src/app/docs/[docsUrl]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DocsSiteLayout } from "@/components/docs-page/DocsSiteLayout";
import { parseDocsUrlParam } from "@/lib/parseDocsUrlParam";
import { parseDocsUrlParam } from "@/utils/parseDocsUrlParam";

export default async function Layout({
params,
Expand Down
2 changes: 1 addition & 1 deletion packages/fern-dashboard/src/app/docs/[docsUrl]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DocsSiteOverviewCard } from "@/components/docs-page/DocsSiteOverviewCard";

import { parseDocsUrlParam } from "../../../lib/parseDocsUrlParam";
import { parseDocsUrlParam } from "../../../utils/parseDocsUrlParam";

export default async function Page(props: {
params: Promise<{ docsUrl: string }>;
Expand Down
4 changes: 2 additions & 2 deletions packages/fern-dashboard/src/app/docs/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { redirect } from "next/navigation";

import { DocsZeroState } from "@/components/docs-page/DocsZeroState";
import { constructDocsUrlParam } from "@/lib/constructDocsUrlParam";
import { getDocsSiteUrl } from "@/lib/getDocsSiteUrl";
import { constructDocsUrlParam } from "@/utils/constructDocsUrlParam";
import { getDocsSiteUrl } from "@/utils/getDocsSiteUrl";

import { getMyDocsSites } from "../actions/getMyDocsSites";

Expand Down
3 changes: 2 additions & 1 deletion packages/fern-dashboard/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ThemeProvider } from "next-themes";

import { ProtectedRoute } from "@/components/auth/ProtectedRoute";
import { AppLayout } from "@/components/layout/AppLayout";
import { auth0 } from "@/lib/auth0";
import { getAuth0Client } from "@/utils/auth0";

import { gtPlanar } from "./fonts";
import "./globals.css";
Expand All @@ -19,6 +19,7 @@ export default async function RootLayout({
}>) {
let content = children;

const auth0 = await getAuth0Client();
const session = await auth0.getSession();
if (session != null) {
content = (
Expand Down
3 changes: 2 additions & 1 deletion packages/fern-dashboard/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { redirect } from "next/navigation";

import { LoginPage } from "@/components/login-page/LoginPage";
import { auth0 } from "@/lib/auth0";
import { getAuth0Client } from "@/utils/auth0";

export default async function Page() {
const auth0 = await getAuth0Client();
const session = await auth0.getSession();

if (session == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";

import { createPersonalProject } from "@/app/actions/createPersonalProject";
import { getMyOrganizations } from "@/app/actions/getMyOrganizations";
import { auth0 } from "@/lib/auth0";
import { getAuth0Client } from "@/utils/auth0";

export declare namespace ProtectedRoute {
export interface Props {
Expand All @@ -12,6 +12,7 @@ export declare namespace ProtectedRoute {
}

export const ProtectedRoute = async ({ children }: ProtectedRoute.Props) => {
const auth0 = await getAuth0Client();
const session = await auth0.getSession();

if (session == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { DocsUrl } from "@/lib/types";
import { useDocsSite } from "@/lib/useMyDocsSites";
import { DocsUrl } from "@/utils/types";
import { useDocsSite } from "@/utils/useMyDocsSites";

import { Page404 } from "../Page404";
import { DocsSiteNavBar } from "./DocsSiteNavBar";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from "next/link";
import { usePathname } from "next/navigation";
import { useMemo } from "react";

import { cn } from "@/lib/cn";
import { cn } from "@/utils/cn";

export declare namespace DocsSiteNavBarItem {
export interface Props {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";

import { unwrapLoadable } from "@/lib/Loadable";
import { getDocsSiteUrl } from "@/lib/getDocsSiteUrl";
import { DocsUrl } from "@/lib/types";
import { useDocsSite } from "@/lib/useMyDocsSites";
import { unwrapLoadable } from "@/utils/Loadable";
import { getDocsSiteUrl } from "@/utils/getDocsSiteUrl";
import { DocsUrl } from "@/utils/types";
import { useDocsSite } from "@/utils/useMyDocsSites";

export declare namespace DocsSiteOverviewCard {
export interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Image from "next/image";
import { User } from "@auth0/nextjs-auth0/types";
import { PlusIcon } from "@heroicons/react/24/outline";

import { getSessionOrRedirect } from "@/lib/auth0";
import { getSessionOrRedirect } from "@/utils/auth0";

import exampleDocsSite from "../../../public/example-docs-site.avif";
import { Button } from "../ui/button";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSessionOrRedirect } from "@/lib/auth0";
import { getSessionOrRedirect } from "@/utils/auth0";

import { Navbar } from "../navbar/Navbar";
import { Header } from "./Header";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { constructDocsUrlParam } from "@/lib/constructDocsUrlParam";
import { getDocsSiteUrl } from "@/lib/getDocsSiteUrl";
import { DocsUrl } from "@/lib/types";
import { constructDocsUrlParam } from "@/utils/constructDocsUrlParam";
import { getDocsSiteUrl } from "@/utils/getDocsSiteUrl";
import { DocsUrl } from "@/utils/types";

export declare namespace DocsSiteSelect {
export interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { useParams } from "next/navigation";

import { parseDocsUrlParam } from "@/lib/parseDocsUrlParam";
import { useMyDocsSites } from "@/lib/useMyDocsSites";
import { parseDocsUrlParam } from "@/utils/parseDocsUrlParam";
import { useMyDocsSites } from "@/utils/useMyDocsSites";

import { DocsSiteSelect } from "./DocsSiteSelect";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

import { cn } from "@/lib/cn";
import { cn } from "@/utils/cn";

export declare namespace FooterText {
export interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import { BookOpenIcon } from "@heroicons/react/24/outline";

import { constructDocsUrlParam } from "@/lib/constructDocsUrlParam";
import { getDocsSiteUrl } from "@/lib/getDocsSiteUrl";
import { useMyDocsSites } from "@/lib/useMyDocsSites";
import { constructDocsUrlParam } from "@/utils/constructDocsUrlParam";
import { getDocsSiteUrl } from "@/utils/getDocsSiteUrl";
import { useMyDocsSites } from "@/utils/useMyDocsSites";

import { DocsNavbarSubItems } from "./DocsNavbarSubItems";
import { ICON_SIZE, NavbarItem } from "./NavbarItem";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import { constructDocsUrlParam } from "@/lib/constructDocsUrlParam";
import { getDocsSiteUrl } from "@/lib/getDocsSiteUrl";
import { useMyDocsSites } from "@/lib/useMyDocsSites";
import { constructDocsUrlParam } from "@/utils/constructDocsUrlParam";
import { getDocsSiteUrl } from "@/utils/getDocsSiteUrl";
import { useMyDocsSites } from "@/utils/useMyDocsSites";

import { NavbarSubItem } from "./NavbarSubItem";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from "next/link";
import { usePathname } from "next/navigation";
import React from "react";

import { cn } from "@/lib/cn";
import { cn } from "@/utils/cn";

export declare namespace NavbarItem {
export interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from "next/link";
import { usePathname } from "next/navigation";
import React from "react";

import { cn } from "@/lib/cn";
import { cn } from "@/utils/cn";

export declare namespace NavbarSubItem {
export interface Props {
Expand Down
2 changes: 1 addition & 1 deletion packages/fern-dashboard/src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { type VariantProps, cva } from "class-variance-authority";

import { cn } from "@/lib/cn";
import { cn } from "@/utils/cn";

const buttonVariants = cva(
"focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive text-gray-1100 inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 dark:text-gray-700 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as React from "react";
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";

import { cn } from "@/lib/cn";
import { cn } from "@/utils/cn";

function DropdownMenu({
...props
Expand Down
2 changes: 1 addition & 1 deletion packages/fern-dashboard/src/components/ui/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as React from "react";

import * as PopoverPrimitive from "@radix-ui/react-popover";

import { cn } from "@/lib/cn";
import { cn } from "@/utils/cn";

function Popover({
...props
Expand Down
2 changes: 1 addition & 1 deletion packages/fern-dashboard/src/components/ui/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as React from "react";
import * as SelectPrimitive from "@radix-ui/react-select";
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";

import { cn } from "@/lib/cn";
import { cn } from "@/utils/cn";

function Select({
...props
Expand Down
36 changes: 0 additions & 36 deletions packages/fern-dashboard/src/lib/auth0.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/fern-dashboard/src/lib/types.ts

This file was deleted.

16 changes: 4 additions & 12 deletions packages/fern-dashboard/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { type NextRequest, NextResponse } from "next/server";
import { type NextRequest } from "next/server";

import { auth0 } from "./lib/auth0";
import { getAuth0Client } from "./utils/auth0";

// copied from https://github.com/auth0/nextjs-auth0/issues/1983
export async function middleware(req: NextRequest) {
const auth0 = await getAuth0Client();
const authResponse = await auth0.middleware(req);

// Process Auth0 middleware
// copied from https://github.com/auth0/nextjs-auth0/issues/1983
if (req.nextUrl.pathname.startsWith("/auth")) {
if (req.nextUrl.pathname === "/auth/login") {
// This is a workaround for this issue: https://github.com/auth0/nextjs-auth0/issues/1917
Expand All @@ -19,16 +19,8 @@ export async function middleware(req: NextRequest) {
}
});
}
return authResponse;
}

const session = await auth0.getSession(req);
// Redirect must only be applied if not logout, otherwise logout doesn't work.
if (!session && !req.nextUrl.pathname.startsWith("/auth/logout")) {
return NextResponse.redirect(new URL("/auth/login", req.nextUrl.origin));
}

// Auth0 middleware response *must* be returned, because of the headers.
return authResponse;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { load } from "../../../fdr-sdk/src/client/generated/api/resources/snippets";

export type Loadable<T> =
| { type: "notStartedLoading" }
| { type: "loading" }
Expand Down
Loading
Loading