Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3955ea7
refactor!: add zod parsing for all env vars and remove individual exp…
seansica Aug 19, 2025
c101e40
build(webapp): install @t3-oss/env-nextjs to support refactored env.ts
seansica Aug 19, 2025
9f29fde
refactor(webapp): update imports and references to environment variables
seansica Aug 19, 2025
af7c396
refactor(webapp): more updates to dependent modules referencing env.ts
seansica Aug 19, 2025
91fde45
build(typescript): switch moduleResolution to bundler
seansica Aug 19, 2025
1a20fe1
build(webapp): upgrade zod to 3.25.76
seansica Aug 19, 2025
49587af
refactor(webapp)\!: consolidate derived config values and decouple co…
seansica Aug 19, 2025
5236cbd
fix(webapp): correct TypeScript syntax for optional country property
seansica Aug 19, 2025
f7889f5
refactor(webapp): update references to lib/env.ts exports
seansica Aug 19, 2025
0141fc1
refactor(webapp): update references to lib/env.ts exports
seansica Aug 19, 2025
35f21c4
fix(webapp): update NextAuthOptions import path in authOptions.ts
seansica Aug 19, 2025
2397678
fix(webapp)\!: resolve import cycle by migrating auth related interfa…
seansica Aug 20, 2025
00aa0a1
fix(webapp): refactor downstream modules to import auth interfaces fr…
seansica Aug 20, 2025
a4024d4
fix(webapp): resolves linting error where imports cannot be found
seansica Aug 20, 2025
d9385b4
refactor(webapp): simplify session user ID check with optional chaining
seansica Aug 20, 2025
5393884
refactor(webapp): add explicit type annotation for session variable
seansica Aug 20, 2025
cae2b57
fix(webapp): eliminate dependency cycle between lib/db/user, lib/db, …
seansica Aug 20, 2025
3c2f564
style(webapp): apply prettier formatting via npm run format:write
seansica Aug 20, 2025
8486dc4
Merge remote-tracking branch 'upstream/main' into 2-environment-varia…
seansica Aug 21, 2025
226ef60
style(webapp): apply prettier formatting via npm run format:write
seansica Aug 21, 2025
263f1d7
fix(webapp): resolve import paths and add graph related env variables
seansica Aug 21, 2025
cb728b0
Merge branch 'main' into 2-environment-variable-handling-improvements
seansica Aug 21, 2025
48e80d4
Merge remote-tracking branch 'upstream/main' into 2-environment-varia…
seansica Aug 22, 2025
83e6467
style(webapp): apply prettier formatting
seansica Aug 22, 2025
f58e556
fix(webapp): update references to environment variables
seansica Aug 22, 2025
93bb38e
Merge remote-tracking branch 'upstream/main' into 2-environment-varia…
seansica Sep 4, 2025
98cc321
refactor(env): centralize environment variable access and clean up im…
seansica Sep 4, 2025
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
6 changes: 3 additions & 3 deletions apps/webapp/app/[modelId]/[layer]/[index]/opengraph-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/* eslint no-nested-ternary: 0 */
/* eslint react/no-array-index-key: 0 */

import { makeAuthedUserFromSessionOrReturnNull } from '@/lib/auth/utils';
import { getNeuronOptimized } from '@/lib/db/neuron';
import { getSourceSet } from '@/lib/db/source';
import { makeAuthedUserFromSessionOrReturnNull } from '@/lib/db/user';
import { NEXT_PUBLIC_URL } from '@/lib/env';
import { env } from '@/lib/env';
import { makeActivationBackgroundColorWithDFA, replaceHtmlAnomalies } from '@/lib/utils/activations';
import { Activation } from '@prisma/client';
import { notFound } from 'next/navigation';
Expand Down Expand Up @@ -352,7 +352,7 @@ export default async function Image({ params }: { params: { modelId: string; lay
})}
</div>
<div tw="absolute flex flex-row justify-end bottom-0 text-slate-400 right-0 pb-2 pr-3 leading-none">
{NEXT_PUBLIC_URL}/{currentNeuron.modelId}/{currentNeuron.layer}/{currentNeuron.index}
{env.NEXT_PUBLIC_URL}/{currentNeuron.modelId}/{currentNeuron.layer}/{currentNeuron.index}
</div>
</div>
),
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/[modelId]/[layer]/[index]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeAuthedUserFromSessionOrReturnNull } from '@/lib/auth/utils';
import { getNeuronOptimized, neuronExistsAndUserHasAccess } from '@/lib/db/neuron';
import { makeAuthedUserFromSessionOrReturnNull } from '@/lib/db/user';
import { NeuronWithPartialRelations } from '@/prisma/generated/zod';
import { Metadata } from 'next';
import { notFound } from 'next/navigation';
Expand Down
4 changes: 2 additions & 2 deletions apps/webapp/app/[modelId]/[layer]/page-source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SearchTopkByTokenPane from '@/components/panes/search-topk-by-token-pane'
import UmapPane from '@/components/panes/umap-pane';
import { BreadcrumbItem, BreadcrumbLink } from '@/components/shadcn/breadcrumbs';
import { getVisibilityBadge } from '@/components/visibility-badge';
import { DEMO_MODE } from '@/lib/env';
import { env } from '@/lib/env';
import { getLayerNumAsStringFromSource } from '@/lib/utils/source';
import {
EvalWithPartialRelations,
Expand Down Expand Up @@ -166,7 +166,7 @@ export default function PageSource({ source }: { source: SourceWithRelations })
/>
)}

{!DEMO_MODE && (
{!env.DEMO_MODE && (
<SAEEvalsPane
sae={source as SourceWithPartialRelations}
evals={source.evals as EvalWithPartialRelations[]}
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/[modelId]/[layer]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeAuthedUserFromSessionOrReturnNull } from '@/lib/auth/utils';
import { getSource, getSourceSet } from '@/lib/db/source';
import { makeAuthedUserFromSessionOrReturnNull } from '@/lib/db/user';
import { getLayerNumAsStringFromSource, getSourceSetNameFromSource } from '@/lib/utils/source';
import { SourceWithRelations } from '@/prisma/generated/zod';
import { Metadata } from 'next';
Expand Down
4 changes: 2 additions & 2 deletions apps/webapp/app/[modelId]/graph/graph-info-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { useGraphContext } from '@/components/provider/graph-provider';
import { Button } from '@/components/shadcn/button';
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@/components/shadcn/dialog';
import { NEXT_PUBLIC_URL } from '@/lib/env';
import { env } from '@/lib/env';
import { DownloadIcon, Info } from 'lucide-react';
import { CLTGraph, CLTGraphQParams } from './graph-types';

Expand Down Expand Up @@ -44,7 +44,7 @@ export default function GraphInfoModal({ cltGraph, selectedMetadataGraph }: Grap

// add current window url to metadata
const location = window.location.href;
const sourceSetUrl = `${NEXT_PUBLIC_URL}/${selectedMetadataGraph.modelId}/${selectedMetadataGraph.sourceSetName}`;
const sourceSetUrl = `${env.NEXT_PUBLIC_URL}/${selectedMetadataGraph.modelId}/${selectedMetadataGraph.sourceSetName}`;
if (data.metadata.info) {
data.metadata.info.neuronpedia_link = location;
data.metadata.info.neuronpedia_source_set = sourceSetUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useGraphModalContext } from '@/components/provider/graph-modal-provider
import { useGraphContext } from '@/components/provider/graph-provider';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/shadcn/dialog';
import { LoadingSquare } from '@/components/svg/loading-square';
import { NEXT_PUBLIC_URL } from '@/lib/env';
import { env } from '@/lib/env';
import { GraphMetadataSubgraph, GraphMetadataSubgraphWithPartialRelations } from '@/prisma/generated/zod';
import copy from 'copy-to-clipboard';
import { Field, Form, Formik } from 'formik';
Expand Down Expand Up @@ -159,7 +159,7 @@ export default function SaveSubgraphModal() {

// Show success view if subgraph was saved
if (savedSubgraph) {
const subgraphUrl = `${NEXT_PUBLIC_URL}/${savedSubgraph.modelId}/graph?slug=${savedSubgraph.slug}&subgraph=${savedSubgraph.subgraphId}`;
const subgraphUrl = `${env.NEXT_PUBLIC_URL}/${savedSubgraph.modelId}/graph?slug=${savedSubgraph.slug}&subgraph=${savedSubgraph.subgraphId}`;

return (
<Dialog
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/[modelId]/graph/modals/welcome-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useGraphModalContext } from '@/components/provider/graph-modal-provider

import { Button } from '@/components/shadcn/button';
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/shadcn/dialog';
import { ASSET_BASE_URL } from '@/lib/env';
import { ASSET_BASE_URL } from '@/lib/constants';
import { MagicWandIcon } from '@radix-ui/react-icons';
import { BookOpen, ChevronRight, Circle, GithubIcon, NewspaperIcon, NotebookIcon } from 'lucide-react';
import { useSearchParams } from 'next/navigation';
Expand Down
9 changes: 4 additions & 5 deletions apps/webapp/app/[modelId]/graph/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { authOptions } from '@/app/api/auth/[...nextauth]/authOptions';
import { GraphProvider } from '@/components/provider/graph-provider';
import { GraphStateProvider } from '@/components/provider/graph-state-provider';
import { ASSET_BASE_URL } from '@/lib/constants';
import { prisma } from '@/lib/db';
import { getModelById } from '@/lib/db/model';
import { ASSET_BASE_URL } from '@/lib/env';
import { ModelWithPartialRelations } from '@/prisma/generated/zod';
import { Metadata } from 'next';
import { getServerSession } from 'next-auth/next';
import { getServerSession, Session } from 'next-auth';
import { notFound } from 'next/navigation';
import { ModelToGraphMetadatasMap } from './graph-types';
import {
Expand Down Expand Up @@ -134,7 +134,7 @@ export default async function Page({
};
}) {
const { modelId } = params;
const session = await getServerSession(authOptions);
const session: Session | null = await getServerSession(authOptions);

const embedParam = searchParams.embed as string | undefined;
const embed = embedParam === 'true';
Expand Down Expand Up @@ -172,8 +172,7 @@ export default async function Page({
searchParams.sourceSet || (ANTHROPIC_MODELS.has(modelId) ? modelId : model?.defaultGraphSourceSetName || '');

// always get the user's graphMetadatas from our database
const graphMetadatas =
session && session.user && session.user.id ? await getGraphMetadataWithUser({ userId: session.user.id }) : [];
const graphMetadatas = session?.user?.id ? await getGraphMetadataWithUser({ userId: session.user.id }) : [];

// add those graphmetadatas to the modelIdToGraphMetadatasMap too
graphMetadatas.forEach((graphMetadata) => {
Expand Down
6 changes: 3 additions & 3 deletions apps/webapp/app/[modelId]/graph/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ATTRIBUTION_GRAPH_SCHEMA from '@/app/api/graph/graph-schema.json';
import { DEFAULT_CREATOR_USER_ID, NEXT_PUBLIC_URL } from '@/lib/env';
import { env } from '@/lib/env';
import { GraphMetadata } from '@/prisma/generated/zod';
import cuid from 'cuid';
import d3 from './d3-jetpack';
Expand Down Expand Up @@ -182,7 +182,7 @@ export function makeGraphPublicAccessGraphUri(modelId: string, slug: string) {
}

export function makeGraphPublicAccessGraphUrl(modelId: string, slug: string) {
return `${NEXT_PUBLIC_URL}${makeGraphPublicAccessGraphUri(modelId, slug)}`;
return `${env.NEXT_PUBLIC_URL}${makeGraphPublicAccessGraphUri(modelId, slug)}`;
}

export function nodeTypeHasFeatureDetail(node: CLTGraphNode): boolean {
Expand Down Expand Up @@ -210,7 +210,7 @@ export async function getGraphMetadatasFromBucket(baseUrl: string): Promise<Mode
prompt: graph.prompt,
titlePrefix: graph.title_prefix,
url: `${baseUrl}/graph_data/${graph.slug}.json`,
userId: DEFAULT_CREATOR_USER_ID,
userId: env.DEFAULT_CREATOR_USER_ID,
id: cuid(),
createdAt: new Date(),
updatedAt: new Date(),
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/[modelId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import BreadcrumbsComponent from '@/components/breadcrumbs-component';
import ModelsDropdown from '@/components/nav/models-dropdown';
import SearchInferenceModelPane from '@/components/panes/search-inference-model-pane';
import { BreadcrumbItem, BreadcrumbLink, BreadcrumbPage } from '@/components/shadcn/breadcrumbs';
import { makeAuthedUserFromSessionOrReturnNull } from '@/lib/auth/utils';
import { getModelById, getModelByIdWithSourceSets } from '@/lib/db/model';
import { getSourceRelease } from '@/lib/db/source';
import { makeAuthedUserFromSessionOrReturnNull } from '@/lib/db/user';
import { getLayerNumAsStringFromSource } from '@/lib/utils/source';
import { SourceReleaseWithRelations } from '@/prisma/generated/zod';
import { Metadata } from 'next';
Expand Down
4 changes: 2 additions & 2 deletions apps/webapp/app/account/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import EditProfileForm from '@/components/edit-profile-form';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/shadcn/card';
import { getUserById } from '@/lib/db/user';
import { getServerSession } from 'next-auth';
import { getServerSession, Session } from 'next-auth';
import { redirect } from 'next/navigation';
import { authOptions } from '../api/auth/[...nextauth]/authOptions';

export default async function Account() {
const session = await getServerSession(authOptions);
const session: Session | null = await getServerSession(authOptions);
if (!session) {
redirect('/signin');
}
Expand Down
8 changes: 4 additions & 4 deletions apps/webapp/app/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getUserById } from '@/lib/db/user';
import { DEMO_MODE, IS_LOCALHOST } from '@/lib/env';
import { getServerSession } from 'next-auth';
import { env } from '@/lib/env';
import { getServerSession, Session } from 'next-auth';
import { authOptions } from '../api/auth/[...nextauth]/authOptions';
import ManageSourcesPane from './manage-sources-pane';

export default async function Page() {
const session = await getServerSession(authOptions);
const session: Session | null = await getServerSession(authOptions);
let isAdminUser = false;
if (session?.user?.id) {
try {
Expand All @@ -15,7 +15,7 @@ export default async function Page() {
console.error('Not admin user', error);
}
}
if (!DEMO_MODE && !IS_LOCALHOST && !isAdminUser) {
if (!env.DEMO_MODE && !env.IS_LOCALHOST && !isAdminUser) {
return <div>Not authorized</div>;
}
return <ManageSourcesPane />;
Expand Down
7 changes: 4 additions & 3 deletions apps/webapp/app/api/activation/get/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ERROR_NOT_FOUND_MESSAGE } from '@/lib/db/userCanAccess';
import { PUBLIC_ACTIVATIONS_USER_IDS } from '@/lib/env';
import { RequestOptionalUser, withOptionalUser } from '@/lib/with-user';
import { env } from '@/lib/env';
import { RequestOptionalUser } from '@/lib/types/auth';
import { withOptionalUser } from '@/lib/with-user';
import { PrismaClient } from '@prisma/client';
import { NextResponse } from 'next/server';

Expand Down Expand Up @@ -66,7 +67,7 @@ export const POST = withOptionalUser(async (request: RequestOptionalUser) => {
layer: source,
index,
creatorId: {
in: PUBLIC_ACTIVATIONS_USER_IDS,
in: env.PUBLIC_ACTIVATIONS_USER_IDS,
},
},
orderBy: {
Expand Down
3 changes: 2 additions & 1 deletion apps/webapp/app/api/activation/new/route.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { assertUserCanAccessModelAndSourceSet } from '@/lib/db/userCanAccess';
import { RequestOptionalUser } from '@/lib/types/auth';
import { getActivationForFeature } from '@/lib/utils/inference';
import { getSourceSetNameFromSource } from '@/lib/utils/source';
import { RequestOptionalUser, withOptionalUser } from '@/lib/with-user';
import { withOptionalUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';

/**
Expand Down
3 changes: 2 additions & 1 deletion apps/webapp/app/api/activation/upload-batch/route.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createActivationsForVector } from '@/lib/db/activation';
import { RequestAuthedUser, withAuthedUser } from '@/lib/with-user';
import { RequestAuthedUser } from '@/lib/types/auth';
import { withAuthedUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';
import { array, number, object, string } from 'yup';

Expand Down
3 changes: 2 additions & 1 deletion apps/webapp/app/api/admin/export-explanations/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { exportExplanations } from '@/lib/db/explanation';
import { RequestAuthedAdminUser, withAuthedAdminUser } from '@/lib/with-user';
import { RequestAuthedAdminUser } from '@/lib/types/auth';
import { withAuthedAdminUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';
import { number, object, string, ValidationError } from 'yup';

Expand Down
3 changes: 2 additions & 1 deletion apps/webapp/app/api/admin/export-features/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { dangerousGetNeuronRangeInternalUseOnly } from '@/lib/db/neuron';
import { RequestAuthedAdminUser, withAuthedAdminUser } from '@/lib/with-user';
import { RequestAuthedAdminUser } from '@/lib/types/auth';
import { withAuthedAdminUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';

export const POST = withAuthedAdminUser(async (request: RequestAuthedAdminUser) => {
Expand Down
7 changes: 4 additions & 3 deletions apps/webapp/app/api/admin/import-config/route.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { importConfigFromS3 } from '@/lib/db/import';
import { IS_LOCALHOST } from '@/lib/env';
import { getAuthedAdminUser, RequestAuthedAdminUser, RequestOptionalUser, withOptionalUser } from '@/lib/with-user';
import { env } from '@/lib/env';
import { RequestAuthedAdminUser, RequestOptionalUser } from '@/lib/types/auth';
import { getAuthedAdminUser, withOptionalUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';

export const GET = withOptionalUser(async (request: RequestOptionalUser) => {
if (!IS_LOCALHOST && request.user && !(await getAuthedAdminUser(request as RequestAuthedAdminUser))) {
if (!env.IS_LOCALHOST && request.user && !(await getAuthedAdminUser(request as RequestAuthedAdminUser))) {
return NextResponse.json({ error: 'This route is only available on localhost or to admin users' }, { status: 400 });
}

Expand Down
7 changes: 4 additions & 3 deletions apps/webapp/app/api/admin/import-file/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
/* eslint-disable no-await-in-loop */

import { importJsonlString } from '@/lib/db/import';
import { IS_LOCALHOST } from '@/lib/env';
import { env } from '@/lib/env';
import { RequestAuthedAdminUser, RequestOptionalUser } from '@/lib/types/auth';
import { downloadAndDecompressFile } from '@/lib/utils/s3';
import { getAuthedAdminUser, RequestAuthedAdminUser, RequestOptionalUser, withOptionalUser } from '@/lib/with-user';
import { getAuthedAdminUser, withOptionalUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';

// Hobby plans don't support > 60 seconds
Expand All @@ -18,7 +19,7 @@ export const POST = withOptionalUser(async (request: RequestOptionalUser) => {
return NextResponse.json({ error: 'path and tableName are required' }, { status: 400 });
}

if (!IS_LOCALHOST && request.user && !(await getAuthedAdminUser(request as RequestAuthedAdminUser))) {
if (!env.IS_LOCALHOST && request.user && !(await getAuthedAdminUser(request as RequestAuthedAdminUser))) {
return NextResponse.json({ error: 'This route is only available on localhost or to admin users' }, { status: 400 });
}
const linesJsonlString = await downloadAndDecompressFile(path);
Expand Down
7 changes: 4 additions & 3 deletions apps/webapp/app/api/admin/import/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

import { prisma } from '@/lib/db';
import { importConfigFromS3, importJsonlString } from '@/lib/db/import';
import { IS_LOCALHOST } from '@/lib/env';
import { env } from '@/lib/env';
import { RequestAuthedAdminUser, RequestOptionalUser } from '@/lib/types/auth';
import {
DATASET_BASE_PATH,
downloadAndDecompressFile,
downloadFileJsonlParsedLines,
getFilesInPath,
} from '@/lib/utils/s3';
import { getAuthedAdminUser, RequestAuthedAdminUser, RequestOptionalUser, withOptionalUser } from '@/lib/with-user';
import { getAuthedAdminUser, withOptionalUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';

// Hobby plans don't support > 60 seconds
Expand All @@ -32,7 +33,7 @@ export const GET = withOptionalUser(async (request: RequestOptionalUser) => {
const path = `${DATASET_BASE_PATH}${modelId}/${sourceId}`;
console.log('Importing data from', path);

if (!IS_LOCALHOST && request.user && !(await getAuthedAdminUser(request as RequestAuthedAdminUser))) {
if (!env.IS_LOCALHOST && request.user && !(await getAuthedAdminUser(request as RequestAuthedAdminUser))) {
return NextResponse.json({ error: 'This route is only available on localhost or to admin users' }, { status: 400 });
}

Expand Down
5 changes: 3 additions & 2 deletions apps/webapp/app/api/admin/new-model/route.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { RequestAuthedAdminUser, withAuthedAdminUser } from '@/lib/with-user';
import { createModelAdmin } from '@/lib/db/model';
import { RequestAuthedAdminUser } from '@/lib/types/auth';
import { withAuthedAdminUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';
import { createModelAdmin } from '../../../../lib/db/model';

type ModelToCreate = {
id: string;
Expand Down
4 changes: 2 additions & 2 deletions apps/webapp/app/api/admin/reset/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IS_LOCALHOST } from '@/lib/env';
import { env } from '@/lib/env';
import { NextResponse } from 'next/server';

export async function POST() {
if (!IS_LOCALHOST) {
if (!env.IS_LOCALHOST) {
return NextResponse.json({ error: 'This route is only available on localhost or to admin users' }, { status: 400 });
}

Expand Down
3 changes: 2 additions & 1 deletion apps/webapp/app/api/admin/upload-autointerp/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createNewExplanationWithoutScore } from '@/lib/db/explanation';
import { RequestAuthedAdminUser, withAuthedAdminUser } from '@/lib/with-user';
import { RequestAuthedAdminUser } from '@/lib/types/auth';
import { withAuthedAdminUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';

type ExplainedFeature = {
Expand Down
9 changes: 5 additions & 4 deletions apps/webapp/app/api/admin/upload-eval/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { prisma } from '@/lib/db';
import { DEFAULT_CREATOR_USER_ID } from '@/lib/env';
import { env } from '@/lib/env';
import { RequestAuthedAdminUser } from '@/lib/types/auth';
import { getSourceSetNameFromSource } from '@/lib/utils/source';
import { RequestAuthedAdminUser, withAuthedAdminUser } from '@/lib/with-user';
import { withAuthedAdminUser } from '@/lib/with-user';
import { Visibility } from '@prisma/client';
import { NextResponse } from 'next/server';

Expand Down Expand Up @@ -47,7 +48,7 @@ export const POST = withAuthedAdminUser(async (request: RequestAuthedAdminUser)
name: getSourceSetNameFromSource(evalUpload.sourceId),
description: '',
creatorName: '',
creatorId: DEFAULT_CREATOR_USER_ID,
creatorId: env.DEFAULT_CREATOR_USER_ID,
hasDashboards: false,
releaseName: SAEBENCH_RELEASE_NAME,
visibility: Visibility.PUBLIC,
Expand All @@ -73,7 +74,7 @@ export const POST = withAuthedAdminUser(async (request: RequestAuthedAdminUser)
modelId: evalUpload.modelId,
id: evalUpload.sourceId,
setName: getSourceSetNameFromSource(evalUpload.sourceId),
creatorId: DEFAULT_CREATOR_USER_ID,
creatorId: env.DEFAULT_CREATOR_USER_ID,
hasDashboards: false,
saelensConfig: evalUpload.saelensConfig,
hfFolderId: evalUpload.hfFolderId,
Expand Down
3 changes: 2 additions & 1 deletion apps/webapp/app/api/admin/upload-sae-config/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { prisma } from '@/lib/db';
import { RequestAuthedAdminUser, withAuthedAdminUser } from '@/lib/with-user';
import { RequestAuthedAdminUser } from '@/lib/types/auth';
import { withAuthedAdminUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';

type SaeConfigUpload = {
Expand Down
3 changes: 2 additions & 1 deletion apps/webapp/app/api/admin/upload-skipped-features/route.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createNeurons } from '@/lib/db/neuron';
import { RequestAuthedAdminUser, withAuthedAdminUser } from '@/lib/with-user';
import { RequestAuthedAdminUser } from '@/lib/types/auth';
import { withAuthedAdminUser } from '@/lib/with-user';
import { NextResponse } from 'next/server';

type SkippedData = {
Expand Down
Loading
Loading