First Commit

This commit is contained in:
2026-09-12 13:56:36 +01:00
commit 4d75af0418
426 changed files with 36452 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
import type { PagePropsType } from "../types";
import userAuth from "../functions/backend/auth/user-auth";
const server: BunextPageServerFn<PagePropsType> = async ({ req, url }) => {
const { user, user_types } = await userAuth({ req });
if (url.pathname.startsWith("/admin") && !user?.logged_in_status) {
return {
redirect: {
destination: "/auth/login",
permanent: false,
},
};
}
if (
url.pathname.startsWith("/auth") &&
!url.pathname.match(/logout/) &&
user?.logged_in_status
) {
return {
redirect: {
destination: "/admin",
permanent: false,
},
};
}
return {
props: {
environment: process.env.NODE_ENV,
envs: {
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID || "",
R2_PUBLIC_DOMAIN: process.env.R2_PUBLIC_DOMAIN || "",
PAYSTACK_PUBLIC_KEY: process.env.PAYSTACK_PUBLIC_KEY || "",
},
user,
user_types,
},
};
};
export default server;