mirror of
				https://github.com/DerTyp7/explainegy-nextjs.git
				synced 2025-10-30 21:27:12 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			691 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			691 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { Request, Response } from "express";
 | |
| import prisma from "../../../lib/prisma";
 | |
| import { Category } from "@prisma/client";
 | |
| import { ResponseError } from "../../../types/responseErrors";
 | |
| 
 | |
| export default async function handler(req: Request, res: Response) {
 | |
|   res.setHeader("Content-Type", "application/json");
 | |
| 
 | |
|   await prisma.category
 | |
|     .findMany({ include: { svg: true } })
 | |
|     .then((result: Category[]) => {
 | |
|       if (result !== null) {
 | |
|         res.end(JSON.stringify(result));
 | |
|       } else {
 | |
|         console.log("No categories found");
 | |
|         res.end(JSON.stringify([]));
 | |
|       }
 | |
|     })
 | |
|     .catch((err) => {
 | |
|       console.log(err);
 | |
|       res.end(JSON.stringify([]));
 | |
|     });
 | |
| }
 | 
