- Replace connect/disconnect pattern with persistent connection pool - Add explicit database initialization on server startup - Remove all dbDisconnect() calls from API endpoints to prevent race conditions - Fix MongoNotConnectedError when scheduler runs concurrently with API requests - Add connection pooling with proper MongoDB driver options - Add safety check for recipes array in favorites utility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
13 lines
436 B
TypeScript
13 lines
436 B
TypeScript
import { json, type RequestHandler } from '@sveltejs/kit';
|
|
import { Recipe } from '../../../../../models/Recipe';
|
|
import { dbConnect } from '../../../../../utils/db';
|
|
import type {BriefRecipeType} from '../../../../../types/types';
|
|
|
|
export const GET: RequestHandler = async ({params}) => {
|
|
await dbConnect();
|
|
let icons = (await Recipe.distinct('icon').lean());
|
|
|
|
icons = JSON.parse(JSON.stringify(icons));
|
|
return json(icons);
|
|
};
|