@ronas-it/nx-generators 0.15.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/generators/code-checks/files/.eslint.ronasit.cjs.template +301 -300
- package/src/generators/code-checks/files/eslint.config.cjs.template +39 -37
- package/src/generators/expo-app/generator.js +1 -1
- package/src/generators/expo-app/generator.js.map +1 -1
- package/src/generators/next-app/generator.js +6 -0
- package/src/generators/next-app/generator.js.map +1 -1
- package/src/shared/dependencies.d.ts +6 -0
- package/src/shared/dependencies.js +6 -0
- package/src/shared/dependencies.js.map +1 -1
- package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/auth/models/refresh-token-response.ts.template +1 -1
- package/src/shared/generators/auth/common-files/shared/data-access/auth/src/lib/store/listener.ts.template +165 -0
- package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/auth/src/lib/store/slice.ts.template +12 -1
- package/src/shared/generators/auth/generator.js +19 -2
- package/src/shared/generators/auth/generator.js.map +1 -1
- package/src/shared/generators/auth/next-app-files/app/[locale]/providers.tsx.template +26 -0
- package/src/shared/generators/auth/next-app-files/middleware.ts.template +33 -0
- package/src/shared/generators/auth/next-libs-files/shared/data-access/cookie/src/config.ts.template +6 -0
- package/src/shared/generators/auth/next-libs-files/shared/data-access/cookie/src/index.ts.template +2 -0
- package/src/shared/generators/auth/next-libs-files/shared/data-access/cookie/src/service.ts.template +28 -0
- package/src/shared/generators/auth/schema.d.ts +3 -0
- package/src/shared/generators/auth/lib-files/shared/data-access/auth/src/lib/store/listener.ts.template +0 -74
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/auth/api.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/auth/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/auth/models/forgot-password-request.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/auth/models/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/auth/models/login-request.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/auth/models/login-response.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/auth/models/register-request.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/auth/models/restore-password-request.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/profile/api.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/profile/config.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/profile/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/profile/models/get-profile-request.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/profile/models/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/profile/types/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/profile/types/relation.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/user/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/user/models/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/api/src/lib/user/models/user.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/auth/src/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/auth/src/lib/index.ts.template +0 -0
- /package/src/shared/generators/auth/{lib-files → common-files}/shared/data-access/auth/src/lib/store/index.ts.template +0 -0
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { createListenerMiddleware, isAnyOf } from '@reduxjs/toolkit';
|
|
2
|
-
import {
|
|
3
|
-
onRequestRefreshTokenInterceptor,
|
|
4
|
-
onResponseRefreshTokenInterceptor,
|
|
5
|
-
RefreshTokenInterceptorOptions,
|
|
6
|
-
tokenInterceptor,
|
|
7
|
-
} from '@ronas-it/axios-api-client';
|
|
8
|
-
import { storeActions } from '@ronas-it/rtkq-entity-api';
|
|
9
|
-
import { authApi, profileApi, LogInResponse } from '<%= libPath %>/shared/data-access/api';
|
|
10
|
-
import { apiService, configuration } from '<%= libPath %>/shared/data-access/api-client';
|
|
11
|
-
import { AppStorageValue, storage } from '<%= libPath %>/shared/data-access/storage';
|
|
12
|
-
import { authActions, authReducerPath, authSelectors, AuthState } from './slice';
|
|
13
|
-
|
|
14
|
-
export const authListenerMiddleware = createListenerMiddleware<{ [authReducerPath]: AuthState }>();
|
|
15
|
-
|
|
16
|
-
authListenerMiddleware.startListening({
|
|
17
|
-
actionCreator: storeActions.init,
|
|
18
|
-
effect: (_, { dispatch }) => {
|
|
19
|
-
const token = storage.getString(AppStorageValue.TOKEN);
|
|
20
|
-
dispatch(authActions.setIsAuthenticated(Boolean(token)));
|
|
21
|
-
|
|
22
|
-
apiService.useInterceptors({
|
|
23
|
-
request: [[tokenInterceptor({ getToken: () => storage.getString(AppStorageValue.TOKEN) ?? '' })]],
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
dispatch(authActions.setIsAppReady(true));
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
authListenerMiddleware.startListening({
|
|
31
|
-
matcher: authApi.internalActions.middlewareRegistered.match,
|
|
32
|
-
effect: (_, { dispatch, getState }) => {
|
|
33
|
-
const options: RefreshTokenInterceptorOptions = {
|
|
34
|
-
configuration: configuration.auth,
|
|
35
|
-
getIsAuthenticated: () => authSelectors.isAuthenticated(getState()),
|
|
36
|
-
runTokenRefreshRequest: async () => {
|
|
37
|
-
const { token } = await dispatch(authApi.endpoints.refreshToken.initiate()).unwrap();
|
|
38
|
-
storage.set(AppStorageValue.TOKEN, token);
|
|
39
|
-
|
|
40
|
-
return token;
|
|
41
|
-
},
|
|
42
|
-
onError: () => {
|
|
43
|
-
return dispatch(authApi.endpoints.logout.initiate()).unwrap();
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
apiService.useInterceptors({
|
|
48
|
-
request: [[onRequestRefreshTokenInterceptor(options)]],
|
|
49
|
-
response: [[null, onResponseRefreshTokenInterceptor(options)]],
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
authListenerMiddleware.startListening({
|
|
55
|
-
matcher: isAnyOf(authApi.endpoints.login.matchFulfilled, authApi.endpoints.register.matchFulfilled),
|
|
56
|
-
effect: ({ payload: { token } }: { payload: LogInResponse }, { dispatch }) => {
|
|
57
|
-
storage.set(AppStorageValue.TOKEN, token);
|
|
58
|
-
dispatch(authActions.setIsAuthenticated(true));
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
authListenerMiddleware.startListening({
|
|
63
|
-
matcher: isAnyOf(
|
|
64
|
-
authApi.endpoints.logout.matchFulfilled,
|
|
65
|
-
authApi.endpoints.logout.matchRejected,
|
|
66
|
-
profileApi.endpoints.deleteProfile.matchFulfilled,
|
|
67
|
-
),
|
|
68
|
-
effect: (_, { dispatch }) => {
|
|
69
|
-
storage.delete(AppStorageValue.TOKEN);
|
|
70
|
-
dispatch(authActions.setIsAuthenticated(false));
|
|
71
|
-
|
|
72
|
-
dispatch(profileApi.util.resetApiState());
|
|
73
|
-
},
|
|
74
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|