prototype: isolate model status fixtures
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { dev } from '$app/environment';
|
||||||
import { json, type Handle, type HandleServerError } from '@sveltejs/kit';
|
import { json, type Handle, type HandleServerError } from '@sveltejs/kit';
|
||||||
import { stringify } from 'devalue';
|
import { stringify } from 'devalue';
|
||||||
import { randomUUID } from 'node:crypto';
|
import { randomUUID } from 'node:crypto';
|
||||||
@@ -15,6 +16,15 @@ import {
|
|||||||
} from '$lib/server/data-moderation';
|
} from '$lib/server/data-moderation';
|
||||||
|
|
||||||
export const handle: Handle = async ({ event, resolve }) => {
|
export const handle: Handle = async ({ event, resolve }) => {
|
||||||
|
// THROWAWAY PROTOTYPE: fixture-only review must not open the shared database.
|
||||||
|
if (
|
||||||
|
dev &&
|
||||||
|
event.url.pathname === '/database' &&
|
||||||
|
event.url.searchParams.get('prototype') === 'model-status'
|
||||||
|
) {
|
||||||
|
return resolve(event);
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
event.url.pathname === '/admin' ||
|
event.url.pathname === '/admin' ||
|
||||||
event.url.pathname.startsWith('/admin/')
|
event.url.pathname.startsWith('/admin/')
|
||||||
|
|||||||
@@ -1,10 +1,26 @@
|
|||||||
|
import { dev } from '$app/environment';
|
||||||
import { getSessionUser } from '$lib/server/auth/session';
|
import { getSessionUser } from '$lib/server/auth/session';
|
||||||
import { hasPermission } from '$lib/server/auth/authorization';
|
import { hasPermission } from '$lib/server/auth/authorization';
|
||||||
import type { LayoutServerLoad } from './$types';
|
import type { LayoutServerLoad } from './$types';
|
||||||
import { notificationSummary } from '$lib/server/notifications';
|
import { notificationSummary } from '$lib/server/notifications';
|
||||||
import { getSiteAccessSettings } from '$lib/server/site-access';
|
import { getSiteAccessSettings } from '$lib/server/site-access';
|
||||||
|
|
||||||
export const load: LayoutServerLoad = async ({ cookies }) => {
|
export const load: LayoutServerLoad = async ({ cookies, url }) => {
|
||||||
|
// THROWAWAY PROTOTYPE: fixture-only review must not open the shared database.
|
||||||
|
if (dev && url.pathname === '/database' && url.searchParams.get('prototype') === 'model-status') {
|
||||||
|
return {
|
||||||
|
user: null,
|
||||||
|
isacAccess: false,
|
||||||
|
notifications: { unread: 0 },
|
||||||
|
siteAccess: {
|
||||||
|
comingSoonEnabled: false,
|
||||||
|
accountCreationEnabled: true,
|
||||||
|
sections: { news: true, database: true, builds: true, guides: true, builder: true },
|
||||||
|
updatedAt: 'prototype'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const user = await getSessionUser(cookies);
|
const user = await getSessionUser(cookies);
|
||||||
return {
|
return {
|
||||||
user,
|
user,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { dev } from '$app/environment';
|
||||||
import { getDatabase } from '$lib/server/database';
|
import { getDatabase } from '$lib/server/database';
|
||||||
import { getRegistrySearch } from '$lib/server/pagination';
|
import { getRegistrySearch } from '$lib/server/pagination';
|
||||||
import { databaseCategories } from '$lib/database/categories';
|
import { databaseCategories } from '$lib/database/categories';
|
||||||
@@ -16,6 +17,11 @@ const tables = {
|
|||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ url }) => {
|
export const load: PageServerLoad = async ({ url }) => {
|
||||||
|
// THROWAWAY PROTOTYPE: avoid opening the shared database for fixture-only review.
|
||||||
|
if (dev && url.searchParams.get('prototype') === 'model-status') {
|
||||||
|
return { registries: [], total: 0, search: '', searchResults: [] };
|
||||||
|
}
|
||||||
|
|
||||||
const database = await getDatabase();
|
const database = await getDatabase();
|
||||||
const { search, pattern } = getRegistrySearch(url);
|
const { search, pattern } = getRegistrySearch(url);
|
||||||
const counts = await Promise.all(
|
const counts = await Promise.all(
|
||||||
|
|||||||
Reference in New Issue
Block a user