Update landing page
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { createRoute, z } from "@hono/zod-openapi";
|
||||
import { DomainSchema } from "~/lib/zod/domain-schema";
|
||||
import { PublicAPIApp } from "../hono";
|
||||
import { db } from "../../db";
|
||||
import { getTeamFromToken } from "../auth";
|
||||
import { PublicAPIApp } from "~/server/public-api/hono";
|
||||
import { db } from "~/server/db";
|
||||
import { getTeamFromToken } from "~/server/public-api/auth";
|
||||
|
||||
const route = createRoute({
|
||||
method: "get",
|
@@ -1,6 +1,6 @@
|
||||
import { createRoute, z } from "@hono/zod-openapi";
|
||||
import { PublicAPIApp } from "../hono";
|
||||
import { getTeamFromToken } from "../auth";
|
||||
import { PublicAPIApp } from "~/server/public-api/hono";
|
||||
import { getTeamFromToken } from "~/server/public-api/auth";
|
||||
import { sendEmail } from "~/server/service/email-service";
|
||||
|
||||
const route = createRoute({
|
@@ -3,6 +3,9 @@ import { hashToken } from "../auth";
|
||||
import { db } from "../db";
|
||||
import { UnsendApiError } from "./api-error";
|
||||
|
||||
/**
|
||||
* Gets the team from the token. Also will check if the token is valid.
|
||||
*/
|
||||
export const getTeamFromToken = async (c: Context) => {
|
||||
const authHeader = c.req.header("Authorization");
|
||||
if (!authHeader) {
|
||||
@@ -11,7 +14,7 @@ export const getTeamFromToken = async (c: Context) => {
|
||||
message: "No Authorization header provided",
|
||||
});
|
||||
}
|
||||
const token = authHeader.split(" ")[1]; // Assuming the Authorization header is in the format "Bearer <token>"
|
||||
const token = authHeader.split(" ")[1];
|
||||
if (!token) {
|
||||
throw new UnsendApiError({
|
||||
code: "UNAUTHORIZED",
|
||||
@@ -38,5 +41,15 @@ export const getTeamFromToken = async (c: Context) => {
|
||||
});
|
||||
}
|
||||
|
||||
// No await so it won't block the request. Need to be moved to a queue in future
|
||||
db.apiKey.update({
|
||||
where: {
|
||||
tokenHash: hashedToken,
|
||||
},
|
||||
data: {
|
||||
lastUsed: new Date(),
|
||||
},
|
||||
});
|
||||
|
||||
return team;
|
||||
};
|
||||
|
@@ -1,10 +1,13 @@
|
||||
import { getApp } from "./hono";
|
||||
import getDomains from "./api/get-domains";
|
||||
import sendEmail from "./api/send-email";
|
||||
import getDomains from "./api/domains/get-domains";
|
||||
import sendEmail from "./api/emails/send-email";
|
||||
|
||||
export const app = getApp();
|
||||
|
||||
/**Domain related APIs */
|
||||
getDomains(app);
|
||||
|
||||
/**Email related APIs */
|
||||
sendEmail(app);
|
||||
|
||||
export default app;
|
||||
|
Reference in New Issue
Block a user