Skip to content

Commit

Permalink
Merge pull request #58 from wtfdivyansh/main
Browse files Browse the repository at this point in the history
fix imports
  • Loading branch information
SkidGod4444 authored Nov 21, 2024
2 parents 41525c6 + 90e17b9 commit a54aef5
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 55 deletions.
4 changes: 1 addition & 3 deletions apps/api/app/api/[[...route]]/auth.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { auth } from "@repo/auth";
import { Hono } from "hono";

const app = new Hono();

app.on(["POST", "GET"], "/**", (c) => {
const app = new Hono().on(["POST", "GET"], "/**", (c) => {
return auth.handler(c.req.raw);
});

Expand Down
3 changes: 1 addition & 2 deletions apps/api/app/api/[[...route]]/health.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Hono } from "hono";
const app = new Hono();
app.get("/", async (c) => {
const app = new Hono().get("/", (c) => {
return c.json({
message: "i am alive",
status: 200,
Expand Down
11 changes: 4 additions & 7 deletions apps/api/app/api/[[...route]]/mail.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Hono } from "hono";
import { sendBatchEmail, sendEmail } from "@repo/mail";
import { mailBatchSchema, mailSchema } from "@repo/types";
import { zValidator } from "@hono/zod-validator";

const app = new Hono();

app
const app = new Hono()
.post("/send", zValidator("json", mailSchema), async (c) => {
const { email, subject } = c.req.valid("json");
const { sendEmail } = await import("@repo/mail");
const { data, error } = await sendEmail(email, subject);
if (error) {
return c.json(
Expand All @@ -30,11 +28,10 @@ app
message: "mail api is alive",
status: 200,
});
});

app
})
.post("/send-batch", zValidator("json", mailBatchSchema), async (c) => {
const { emails, subject } = c.req.valid("json");
const { sendBatchEmail } = await import("@repo/mail");
const { data, error } = await sendBatchEmail(emails, subject);
if (error) {
return c.json(
Expand Down
4 changes: 2 additions & 2 deletions apps/api/app/api/[[...route]]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Hono } from "hono";
import { auth as Auth } from "@repo/auth";
import { cors } from "hono/cors";
import mail from "./mail";
import hello from "./test";
import test from "./test";
import session from "./session";
import auth from "./auth";
import status from "./status";
Expand Down Expand Up @@ -38,7 +38,7 @@ app.use(

app.route("/health", health);
app.route("/session", session);
app.route("/test", hello);
app.route("/test", test);
app.route("/mail", mail);
app.route("/auth", auth);
app.route("/status", status);
Expand Down
28 changes: 13 additions & 15 deletions apps/api/app/api/[[...route]]/session.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { Hono } from "hono";
import { auth } from "@repo/auth";

const app = new Hono();
const app = new Hono()
.get("/", async (c) => {
const session = await auth.api.getSession({ headers: c.req.raw.headers });

app.get("/", async (c) => {
const session = await auth.api.getSession({ headers: c.req.raw.headers });
if (!session) return c.json({ message: "no session found" }, 401);

if (!session) return c.json({ message: "no session found" }, 401);

return c.json({
session,
});
});

app.get("/all", async (c) => {
const res = await auth.api.listDeviceSessions({
headers: c.req.raw.headers,
return c.json({
session,
});
})
.get("/all", async (c) => {
const res = await auth.api.listDeviceSessions({
headers: c.req.raw.headers,
});
return c.json(res);
});
return c.json(res);
});

export default app;
43 changes: 20 additions & 23 deletions apps/api/app/api/[[...route]]/status.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import { Hono } from "hono";
import { cache } from "@repo/cache";

const app = new Hono();

app.get("/", async (c) => {
const dbStatus = await cache.lrange("db-latency:history", 0, -1);
const siteStatus = await cache.lrange("site-latency:history", 0, -1);
return c.json({
dbStatus,
siteStatus,
});
});

app.get("/db", async (c) => {
const dbStatus = await cache.lrange("db-latency:history", 0, -1);
return c.json({
dbStatus,
});
});

app.get("/site", async (c) => {
const siteStatus = await cache.lrange("site-latency:history", 0, -1);
return c.json({
siteStatus,
const app = new Hono()
.get("/", async (c) => {
const dbStatus = await cache.lrange("db-latency:history", 0, -1);
const siteStatus = await cache.lrange("site-latency:history", 0, -1);
return c.json({
dbStatus,
siteStatus,
});
})
.get("/db", async (c) => {
const dbStatus = await cache.lrange("db-latency:history", 0, -1);
return c.json({
dbStatus,
});
})
.get("/site", async (c) => {
const siteStatus = await cache.lrange("site-latency:history", 0, -1);
return c.json({
siteStatus,
});
});
});

export default app;
4 changes: 1 addition & 3 deletions apps/api/app/api/[[...route]]/test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Hono } from "hono";
import { prisma } from "@repo/db";

const app = new Hono();

app.get("/", async (c) => {
const app = new Hono().get("/", async (c) => {
const user = await prisma.user.findMany();
return c.json({
user,
Expand Down

0 comments on commit a54aef5

Please sign in to comment.