bump prisma to 7

This commit is contained in:
fred 2026-01-28 08:12:06 -08:00
parent 081145f900
commit 96443b6afe
9 changed files with 815 additions and 117 deletions

File diff suppressed because it is too large Load diff

View file

@ -12,20 +12,22 @@
"license": "ISC",
"description": "",
"dependencies": {
"@prisma/client": "^6.14.0",
"@prisma/adapter-pg": "7.2.0",
"@prisma/client": "7.2.0",
"cors": "^2.8.5",
"dotenv": "^17.0.1",
"express": "^5.1.0",
"knex": "^3.1.0",
"pg": "^8.16.3",
"prisma": "^6.14.0"
"pg": "^8.17.2",
"prisma": "7.2.0"
},
"devDependencies": {
"typescript": "^5.9.2",
"ts-node": "^10.9.2",
"@types/node": "^24.2.1",
"@types/cors": "^2.8.19",
"@types/express": "^5.0.3",
"nodemon": "^3.1.10"
"@types/node": "^24.2.1",
"@types/pg": "^8.16.0",
"nodemon": "^3.1.10",
"ts-node": "^10.9.2",
"typescript": "^5.9.2"
}
}

12
backend/prisma.config.ts Normal file
View file

@ -0,0 +1,12 @@
import 'dotenv/config';
import { defineConfig } from 'prisma/config';
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
datasource: {
url: process.env['DATABASE_URL'],
},
});

View file

@ -1,6 +1,5 @@
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {

View file

@ -1,7 +1,12 @@
import { Request, Response } from "express";
import RecipeModel from "../models/recipeModel";
import { PrismaClient } from "@prisma/client";
const model = new RecipeModel();
let model: RecipeModel;
export const initializeController = (prisma: PrismaClient) => {
model = new RecipeModel(prisma);
};
export const test = async (req: Request, res: Response): Promise<void> => {
console.log("test");

View file

@ -1,24 +1,35 @@
import "dotenv/config";
import express, { Express } from "express";
import cors from "cors";
import { PrismaClient } from "@prisma/client";
import { PrismaPg } from "@prisma/adapter-pg";
import appRoutes from "./routes/appRoutes";
import { initializeController } from "./controllers/recipeController";
const app: Express = express();
const port = process.env.PORT || 3000;
const prisma = new PrismaClient();
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL,
});
const prisma = new PrismaClient({ adapter });
initializeController(prisma);
function setupMiddleware(app: Express) {
app.use(cors());
app.use(express.json());
app.use("/api", appRoutes);
}
setupMiddleware(app);
// Start server
async function startServer() {
try {
app.listen(port);
console.log(`Server is running on http://localhost:${port}`);
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
} catch (error) {
console.error("Error starting the server:", error);
}

View file

@ -6,8 +6,8 @@ const logger = new Logger();
class RecipeModel {
private prisma: PrismaClient;
constructor() {
this.prisma = new PrismaClient();
constructor(prisma: PrismaClient) {
this.prisma = prisma;
}
async getAllRecipes(): Promise<any[]> {
@ -40,11 +40,18 @@ class RecipeModel {
prep_minutes: recipe.prep_minutes,
cook_minutes: recipe.cook_minutes,
},
ingredients: recipe.recipeIngredients.map((ing) => ing.raw),
steps: recipe.recipeSteps.map((step) => ({
step_number: step.step_number,
instruction: step.instruction,
})),
ingredients: recipe.recipeIngredients.map(
(ing: { raw: string | null }) => ing.raw,
),
steps: recipe.recipeSteps.map(
(step: {
step_number: number | null;
instruction: string | null;
}) => ({
step_number: step.step_number ?? 0, // Default to 0 if null
instruction: step.instruction ?? "", // Default to empty string if null
}),
),
};
logger.info("recipe page view", {
recipe_id: data.details.id,