mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 20:36:27 +00:00
Refactor/upgrade backend and frontend parts (#2)
* ♻️ Refactor and simplify backend code * ♻️ Refactor frontend state, integrate typesafe-vuex accessors into state files * ♻️ Use new state accessors and standardize layout * 🔒 Upgrade and fix npm security audit * 🔧 Update local re-generation scripts * 🔊 Log startup exceptions to detect errors early * ✏️ Fix password reset token content * 🔥 Remove unneeded Dockerfile directives * 🔥 Remove unnecessary print * 🔥 Remove unnecessary code, upgrade dependencies in backend * ✏️ Fix typos in docstrings and comments * 🏗️ Improve user Depends utilities to simplify and remove code * 🔥 Remove deprecated SQLAlchemy parameter
This commit is contained in:
committed by
GitHub
parent
9e0b826618
commit
cd112bd683
@@ -1,9 +0,0 @@
|
||||
import { getStoreAccessors } from 'typesafe-vuex';
|
||||
import { State } from '@/store/state';
|
||||
import { mutations } from '../mutations';
|
||||
import { AdminState } from '../state';
|
||||
|
||||
const {commit} = getStoreAccessors<AdminState, State>('');
|
||||
|
||||
export const commitSetUser = commit(mutations.setUser);
|
||||
export const commitSetUsers = commit(mutations.setUsers);
|
||||
@@ -1,10 +0,0 @@
|
||||
import { getStoreAccessors } from 'typesafe-vuex';
|
||||
import { AdminState } from '../state';
|
||||
import { State } from '@/store/state';
|
||||
import { actions } from '../actions';
|
||||
|
||||
const {dispatch} = getStoreAccessors<AdminState, State>('');
|
||||
|
||||
export const dispatchCreateUser = dispatch(actions.actionCreateUser);
|
||||
export const dispatchGetUsers = dispatch(actions.actionGetUsers);
|
||||
export const dispatchUpdateUser = dispatch(actions.actionUpdateUser);
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from './commit';
|
||||
export * from './dispatch';
|
||||
export * from './read';
|
||||
@@ -1,9 +0,0 @@
|
||||
import { getStoreAccessors } from 'typesafe-vuex';
|
||||
import { AdminState } from '../state';
|
||||
import { State } from '@/store/state';
|
||||
import { getters } from '../getters';
|
||||
|
||||
const { read } = getStoreAccessors<AdminState, State>('');
|
||||
|
||||
export const readAdminOneUser = read(getters.adminOneUser);
|
||||
export const readAdminUsers = read(getters.adminUsers);
|
||||
@@ -1,13 +1,12 @@
|
||||
import { api } from '@/api';
|
||||
import { ActionContext } from 'vuex';
|
||||
import {
|
||||
commitSetUsers,
|
||||
commitSetUser,
|
||||
} from './accessors/commit';
|
||||
import { IUserProfileCreate, IUserProfileUpdate } from '@/interfaces';
|
||||
import { State } from '../state';
|
||||
import { AdminState } from './state';
|
||||
import { dispatchCheckApiError, commitAddNotification, commitRemoveNotification } from '../main/accessors';
|
||||
import { getStoreAccessors } from 'typesafe-vuex';
|
||||
import { commitSetUsers, commitSetUser } from './mutations';
|
||||
import { dispatchCheckApiError } from '../main/actions';
|
||||
import { commitAddNotification, commitRemoveNotification } from '../main/mutations';
|
||||
|
||||
type MainContext = ActionContext<AdminState, State>;
|
||||
|
||||
@@ -32,7 +31,7 @@ export const actions = {
|
||||
]))[0];
|
||||
commitSetUser(context, response.data);
|
||||
commitRemoveNotification(context, loadingNotification);
|
||||
commitAddNotification(context, {content: 'User successfully updated', color: 'success'});
|
||||
commitAddNotification(context, { content: 'User successfully updated', color: 'success' });
|
||||
} catch (error) {
|
||||
await dispatchCheckApiError(context, error);
|
||||
}
|
||||
@@ -53,3 +52,9 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const { dispatch } = getStoreAccessors<AdminState, State>('');
|
||||
|
||||
export const dispatchCreateUser = dispatch(actions.actionCreateUser);
|
||||
export const dispatchGetUsers = dispatch(actions.actionGetUsers);
|
||||
export const dispatchUpdateUser = dispatch(actions.actionUpdateUser);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { AdminState } from './state';
|
||||
import { getStoreAccessors } from 'typesafe-vuex';
|
||||
import { State } from '../state';
|
||||
|
||||
export const getters = {
|
||||
adminUsers: (state: AdminState) => state.users,
|
||||
@@ -9,3 +11,8 @@ export const getters = {
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const { read } = getStoreAccessors<AdminState, State>('');
|
||||
|
||||
export const readAdminOneUser = read(getters.adminOneUser);
|
||||
export const readAdminUsers = read(getters.adminUsers);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { IUserProfile } from '@/interfaces';
|
||||
import { AdminState } from './state';
|
||||
import { getStoreAccessors } from 'typesafe-vuex';
|
||||
import { State } from '../state';
|
||||
|
||||
export const mutations = {
|
||||
setUsers(state: AdminState, payload: IUserProfile[]) {
|
||||
@@ -11,3 +13,8 @@ export const mutations = {
|
||||
state.users = users;
|
||||
},
|
||||
};
|
||||
|
||||
const { commit } = getStoreAccessors<AdminState, State>('');
|
||||
|
||||
export const commitSetUser = commit(mutations.setUser);
|
||||
export const commitSetUsers = commit(mutations.setUsers);
|
||||
|
||||
Reference in New Issue
Block a user