### Run Development Server (Shell) Source: https://github.com/spronu/projectc/blob/main/README.md Navigates to the src directory and starts the development server using pnpm dev. This command typically watches for file changes and provides hot-reloading. ```Shell cd src pnpm dev ``` -------------------------------- ### Build Application (Shell) Source: https://github.com/spronu/projectc/blob/main/README.md Navigates to the src directory and runs the pnpm build command to create a production build of the application. This compiles and optimizes the code. ```Shell cd src pnpm build ``` -------------------------------- ### Starting Next.js Development Server (Bash) Source: https://github.com/spronu/projectc/blob/main/src/README.md These commands initiate the local development server for the Next.js application. Running any of these commands will start the server, typically accessible at http://localhost:3000, allowing for live code updates during development. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Generate Prisma Types (Shell) Source: https://github.com/spronu/projectc/blob/main/README.md Navigates to the src directory and runs the Prisma generate command using pnpx to create TypeScript types from the Prisma schema. Requires the Prisma CLI to be installed. ```Shell cd src pnpx prisma generate ``` -------------------------------- ### Run Tests (Shell) Source: https://github.com/spronu/projectc/blob/main/README.md Executes the test suite for the application using pnpm test. Requires the development server to be running on port 3000 beforehand. ```Shell pnpm test ``` -------------------------------- ### Seed Database (Shell) Source: https://github.com/spronu/projectc/blob/main/README.md Executes the Prisma database seed script using npx. Note: It is explicitly recommended to use npx instead of pnpx for this command due to known issues with pnpm. ```Shell npx prisma db seed ``` -------------------------------- ### Handling User Login with Next.js API Route (TypeScript) Source: https://github.com/spronu/projectc/blob/main/src/app/agenda/notes.txt This snippet defines a Next.js API route handler for POST requests to authenticate users. It checks the request method, parses the request body for email and password, queries the database for the user, compares the provided password with the stored hash using bcrypt, and returns a success or failure response with appropriate HTTP status codes. It requires NextResponse, Prisma, and bcrypt. ```TypeScript import { NextResponse } from "next/server"; import prisma from "../../../lib/prisma"; import bcrypt from "bcrypt"; export async function POST(request: Request): Promise { try { if (request.method !== "POST") { return new NextResponse( JSON.stringify({ message: "Method Not Allowed" }), { status: 405 } ); } const body = await request.json(); const { email, password } = body; const user = await prisma.users.findUnique({ where: { email } }); if (!user || !(await bcrypt.compare(password, user.password))) { return new NextResponse( JSON.stringify({ message: "Incorrecte Inloggegevens" }), { status: 401 } ); } return new NextResponse( JSON.stringify({ message: "Succesvol Ingelogd", userId: user.id }), { status: 200 } ); } catch (error) { console.error("Login error:", error); return new NextResponse(JSON.stringify({ message: "Server error" }), { status: 500, }); } } ``` -------------------------------- ### Updating User First Login Status (Commented Out Next.js API Route - TypeScript) Source: https://github.com/spronu/projectc/blob/main/src/app/agenda/notes.txt This commented-out snippet defines a Next.js API route handler for PUT requests to update a user's firstLogin status in the database. It expects id and firstLogin in the request body, uses Prisma to update the user record, and returns the updated user or a server error response. It requires NextApiRequest, NextApiResponse, and Prisma. ```TypeScript /*import type { NextApiRequest, NextApiResponse } from "next"; import prisma from "../../lib/prisma"; export default async function handler( req: NextApiRequest, res: NextApiResponse ) { if (req.method === "PUT") { const { id, firstLogin } = req.body; try { const updatedUser = await prisma.users.update({ where: { id }, data: { firstLogin }, }); res.status(200).json(updatedUser); } catch (error) { console.error("Update user error:", error); res.status(500).json({ message: "Server error" }); } } else { res.status(405).json({ message: "Method Not Allowed" }); } } */ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.