mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 04:35:40 +00:00
refactor: rework file structure (#325)
* wip: add middlewares * refactor: use context fom middleware in handlers * refactor: use controller approach in handlers * refactor: move oauth providers into services (non-working) * feat: create oauth broker service * refactor: use a boostrap service to bootstrap the app * refactor: split utils into smaller files * refactor: use more clear name for frontend assets * feat: allow customizability of resources dir * fix: fix typo in ui middleware * fix: validate resource file paths in ui middleware * refactor: move resource handling to a controller * feat: add some logging * fix: configure middlewares before groups * fix: use correct api path in login mutation * fix: coderabbit suggestions * fix: further coderabbit suggestions
This commit is contained in:
@@ -15,7 +15,7 @@ export const AppContextProvider = ({
|
||||
}) => {
|
||||
const { isFetching, data, error } = useSuspenseQuery({
|
||||
queryKey: ["app"],
|
||||
queryFn: () => axios.get("/api/app").then((res) => res.data),
|
||||
queryFn: () => axios.get("/api/context/app").then((res) => res.data),
|
||||
});
|
||||
|
||||
if (error && !isFetching) {
|
||||
|
||||
@@ -15,7 +15,7 @@ export const UserContextProvider = ({
|
||||
}) => {
|
||||
const { isFetching, data, error } = useSuspenseQuery({
|
||||
queryKey: ["user"],
|
||||
queryFn: () => axios.get("/api/user").then((res) => res.data),
|
||||
queryFn: () => axios.get("/api/context/user").then((res) => res.data),
|
||||
});
|
||||
|
||||
if (error && !isFetching) {
|
||||
|
||||
@@ -65,7 +65,7 @@ export const LoginPage = () => {
|
||||
});
|
||||
|
||||
const loginMutation = useMutation({
|
||||
mutationFn: (values: LoginSchema) => axios.post("/api/login", values),
|
||||
mutationFn: (values: LoginSchema) => axios.post("/api/user/login", values),
|
||||
mutationKey: ["login"],
|
||||
onSuccess: (data) => {
|
||||
if (data.data.totpPending) {
|
||||
|
||||
@@ -26,7 +26,7 @@ export const LogoutPage = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const logoutMutation = useMutation({
|
||||
mutationFn: () => axios.post("/api/logout"),
|
||||
mutationFn: () => axios.post("/api/user/logout"),
|
||||
mutationKey: ["logout"],
|
||||
onSuccess: () => {
|
||||
toast.success(t("logoutSuccessTitle"), {
|
||||
|
||||
@@ -32,7 +32,7 @@ export const TotpPage = () => {
|
||||
const redirectUri = searchParams.get("redirect_uri");
|
||||
|
||||
const totpMutation = useMutation({
|
||||
mutationFn: (values: TotpSchema) => axios.post("/api/totp", values),
|
||||
mutationFn: (values: TotpSchema) => axios.post("/api/user/totp", values),
|
||||
mutationKey: ["totp"],
|
||||
onSuccess: () => {
|
||||
toast.success(t("totpSuccessTitle"), {
|
||||
|
||||
@@ -19,6 +19,11 @@ export default defineConfig({
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, ""),
|
||||
},
|
||||
"/resources": {
|
||||
target: "http://tinyauth-backend:3000/resources",
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/resources/, ""),
|
||||
},
|
||||
},
|
||||
allowedHosts: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user