Skip to content

Commit 41525c6

Browse files
authored
Merge pull request #57 from wtfdivyansh/main
refactor api
2 parents a3cb0e0 + 95f5116 commit 41525c6

File tree

4 files changed

+27
-69
lines changed

4 files changed

+27
-69
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Hono } from "hono";
2+
const app = new Hono();
3+
app.get("/", async (c) => {
4+
return c.json({
5+
message: "i am alive",
6+
status: 200,
7+
});
8+
});
9+
10+
export default app;

apps/api/app/api/[[...route]]/hello.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

apps/api/app/api/[[...route]]/route.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { Hono } from "hono";
33
import { auth as Auth } from "@repo/auth";
44
import { cors } from "hono/cors";
55
import mail from "./mail";
6-
import hello from "./hello";
6+
import hello from "./test";
77
import session from "./session";
88
import auth from "./auth";
99
import status from "./status";
10+
import health from "./health";
1011

1112
const allowedOrigins = [
1213
"http://localhost:3003",
@@ -34,29 +35,10 @@ app.use(
3435
credentials: true,
3536
}),
3637
);
37-
app.use("*", async (c, next) => {
38-
const session = await Auth.api.getSession({ headers: c.req.raw.headers });
39-
40-
if (!session) {
41-
c.set("user", null);
42-
c.set("session", null);
43-
return next();
44-
}
45-
46-
c.set("user", session.user);
47-
c.set("session", session.session);
48-
return next();
49-
});
50-
51-
app.get("/health", async (c) => {
52-
return c.json({
53-
message: "i am alive",
54-
status: 200,
55-
});
56-
});
5738

39+
app.route("/health", health);
5840
app.route("/session", session);
59-
app.route("/hello", hello);
41+
app.route("/test", hello);
6042
app.route("/mail", mail);
6143
app.route("/auth", auth);
6244
app.route("/status", status);

apps/api/app/api/[[...route]]/test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Hono } from "hono";
2+
import { prisma } from "@repo/db";
3+
4+
const app = new Hono();
5+
6+
app.get("/", async (c) => {
7+
const user = await prisma.user.findMany();
8+
return c.json({
9+
user,
10+
});
11+
});
12+
13+
export default app;

0 commit comments

Comments
 (0)