-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added prettier, fixed code formatting
- Loading branch information
Showing
51 changed files
with
2,887 additions
and
1,640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
semi: false, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import prisma from "@/lib/prisma"; | ||
import { hash } from "bcrypt"; | ||
import { NextResponse } from "next/server"; | ||
import prisma from '@/lib/prisma' | ||
import { hash } from 'bcrypt' | ||
import { NextResponse } from 'next/server' | ||
|
||
export async function POST(req: Request) { | ||
const { name, email, password } = await req.json(); | ||
const { name, email, password } = await req.json() | ||
const exists = await prisma.user.findUnique({ | ||
where: { | ||
email, | ||
}, | ||
}); | ||
}) | ||
if (exists) { | ||
return NextResponse.json({ error: "User already exists" }, { status: 400 }); | ||
return NextResponse.json({ error: 'User already exists' }, { status: 400 }) | ||
} else { | ||
const user = await prisma.user.create({ | ||
data: { | ||
name, | ||
email, | ||
password: await hash(password, 10), | ||
}, | ||
}); | ||
return NextResponse.json(user); | ||
}) | ||
return NextResponse.json(user) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
import { NextResponse } from "next/server"; | ||
import { Ingredient, PrismaClient } from "@prisma/client"; | ||
const prisma = new PrismaClient(); | ||
import { NextResponse } from 'next/server' | ||
import { Ingredient, PrismaClient } from '@prisma/client' | ||
const prisma = new PrismaClient() | ||
|
||
export const PATCH = async (req: Request, {params}: {params: {id: string}}) =>{ | ||
const body: Ingredient= await req.json(); | ||
const ingredient= await prisma.ingredient.update({ | ||
where:{ | ||
id: Number(params.id) | ||
}, | ||
data:{ | ||
name: body.name, | ||
categoryId: body.categoryId | ||
} | ||
}); | ||
return NextResponse.json(ingredient, {status: 200}); | ||
export const PATCH = async ( | ||
req: Request, | ||
{ params }: { params: { id: string } }, | ||
) => { | ||
const body: Ingredient = await req.json() | ||
const ingredient = await prisma.ingredient.update({ | ||
where: { | ||
id: Number(params.id), | ||
}, | ||
data: { | ||
name: body.name, | ||
categoryId: body.categoryId, | ||
}, | ||
}) | ||
return NextResponse.json(ingredient, { status: 200 }) | ||
} | ||
|
||
export const DELETE = async (req: Request, {params}: {params: {id: string}}) =>{ | ||
const ingredient = await prisma.ingredient.delete({ | ||
where:{ | ||
id: Number(params.id) | ||
} | ||
}); | ||
return NextResponse.json(ingredient, {status: 200}); | ||
} | ||
export const DELETE = async ( | ||
req: Request, | ||
{ params }: { params: { id: string } }, | ||
) => { | ||
const ingredient = await prisma.ingredient.delete({ | ||
where: { | ||
id: Number(params.id), | ||
}, | ||
}) | ||
return NextResponse.json(ingredient, { status: 200 }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import { NextResponse } from "next/server"; | ||
import { PrismaClient, Order } from "@prisma/client"; | ||
const prisma = new PrismaClient(); | ||
import { NextResponse } from 'next/server' | ||
import { PrismaClient, Order } from '@prisma/client' | ||
const prisma = new PrismaClient() | ||
|
||
export const PATCH = async ( | ||
req: Request, | ||
{ params }: { params: { id: string } } | ||
{ params }: { params: { id: string } }, | ||
) => { | ||
const body: Order = await req.json(); | ||
const body: Order = await req.json() | ||
const order = await prisma.order.update({ | ||
where: { | ||
id: Number(params.id), | ||
}, | ||
data: { | ||
isPaid: body.isPaid, | ||
}, | ||
}); | ||
return NextResponse.json(order, { status: 200 }); | ||
}; | ||
}) | ||
return NextResponse.json(order, { status: 200 }) | ||
} | ||
|
||
export const DELETE = async ( | ||
req: Request, | ||
{ params }: { params: { id: string } } | ||
{ params }: { params: { id: string } }, | ||
) => { | ||
const recipe = await prisma.order.delete({ | ||
where: { | ||
id: Number(params.id), | ||
}, | ||
}); | ||
return NextResponse.json(recipe, { status: 200 }); | ||
}; | ||
}) | ||
return NextResponse.json(recipe, { status: 200 }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
2534f0c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
pantry-pilot-2 – ./
pantry-pilot-2.vercel.app
pantry-pilot-2-git-main-wtanardi.vercel.app
pantry-pilot-2-wtanardi.vercel.app