Skip to content

Commit

Permalink
chore: format code with Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 6, 2024
1 parent 043543c commit a22c4fc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 43 deletions.
81 changes: 41 additions & 40 deletions apps/api/app/api/[[...route]]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,52 @@ export const runtime = "nodejs";

const app = new Hono().basePath("/api");

app.get("/hello",async(c) => {
const test = await prisma.user.findMany()
return c.json({
test
});
})
.patch( async(c) => {
const name = await c.req.json()
const test = await prisma.user.update({
where: {
id: "123",
},
data: {
name:name.name
}
app
.get("/hello", async (c) => {
const test = await prisma.user.findMany();
return c.json({
test,
});
})
return c.json({
test
});
})
.delete( async(c) => {
const test = await prisma.user.delete({
where: {
id: "2",
}
.patch(async (c) => {
const name = await c.req.json();
const test = await prisma.user.update({
where: {
id: "123",
},
data: {
name: name.name,
},
});
return c.json({
test,
});
})
return c.json({
test
});
})
.post(async(c) => {
const body = await c.req.json()
console.log(body)
const test = await prisma.user.create({
data: body
.delete(async (c) => {
const test = await prisma.user.delete({
where: {
id: "2",
},
});
return c.json({
test,
});
})
return c.json({
test
.post(async (c) => {
const body = await c.req.json();
console.log(body);
const test = await prisma.user.create({
data: body,
});
return c.json({
test,
});
});
});

app.get("/health", async(c) => {
app.get("/health", async (c) => {
return c.json({
message:"i am alive",
status:200
message: "i am alive",
status: 200,
});
});

Expand All @@ -59,4 +60,4 @@ const POST = handle(app);
const PATCH = handle(app);
const DELETE = handle(app);

export {GET, PATCH, POST, DELETE}
export { GET, PATCH, POST, DELETE };
12 changes: 9 additions & 3 deletions apps/api/tests/hello.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ describe("API Routes", () => {
const mockUsers = [{ id: "123", name: "New User" }];
prisma.user.findMany.mockResolvedValue(mockUsers);

const req = new Request("http:/localhost:3000/api/hello", { method: "GET" });
const req = new Request("http:/localhost:3000/api/hello", {
method: "GET",
});
const res = await GET(req);

expect(res.status).toBe(200);
Expand Down Expand Up @@ -68,7 +70,9 @@ describe("API Routes", () => {
const deletedUser = { id: "2", name: "Deleted User" };
prisma.user.delete.mockResolvedValue(deletedUser);

const req = new Request("http:/localhost:3000/api/hello", { method: "DELETE" });
const req = new Request("http:/localhost:3000/api/hello", {
method: "DELETE",
});
const res = await DELETE(req);

expect(res.status).toBe(200);
Expand All @@ -77,7 +81,9 @@ describe("API Routes", () => {
});

it("GET /api/health should return health status", async () => {
const req = new Request("http:/localhost:3000/api/health", { method: "GET" });
const req = new Request("http:/localhost:3000/api/health", {
method: "GET",
});
const res = await GET(req);

expect(res.status).toBe(200);
Expand Down

0 comments on commit a22c4fc

Please sign in to comment.