bump prisma to 7
This commit is contained in:
parent
081145f900
commit
96443b6afe
9 changed files with 815 additions and 117 deletions
840
backend/package-lock.json
generated
840
backend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -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
12
backend/prisma.config.ts
Normal 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'],
|
||||
},
|
||||
});
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
generator client {
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,6 @@ services:
|
|||
- "${FRONTEND_PORT}:80"
|
||||
volumes:
|
||||
- ./frontend:/usr/src/app
|
||||
- "$FRONTEND_BUILD_DIR:/usr/src/app/dist"
|
||||
- ./dist/recipes_frontend:/usr/src/app/dist
|
||||
environment:
|
||||
- NODE_ENV=${NODE_ENV}
|
||||
|
|
|
|||
14
shell.nix
Normal file
14
shell.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
pkgs.mkShell {
|
||||
buildInputs = [
|
||||
pkgs.prisma-engines
|
||||
pkgs.prisma
|
||||
];
|
||||
shellHook = ''
|
||||
export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig"
|
||||
export PRISMA_SCHEMA_ENGINE_BINARY="${pkgs.prisma-engines}/bin/schema-engine"
|
||||
export PRISMA_QUERY_ENGINE_BINARY="${pkgs.prisma-engines}/bin/query-engine"
|
||||
export PRISMA_QUERY_ENGINE_LIBRARY="${pkgs.prisma-engines}/lib/libquery_engine.node"
|
||||
export PRISMA_FMT_BINARY="${pkgs.prisma-engines}/bin/prisma-fmt"
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue