From 9abc82c26b3e6fd129e7ad4186ad1d0d5bfe4e63 Mon Sep 17 00:00:00 2001 From: Renan Franca Date: Mon, 7 Oct 2024 08:54:50 -0300 Subject: [PATCH] docs: add router.ts and main.ts instructions in vue-jwt-authentication-components.md.mustache --- ...-jwt-authentication-components.md.mustache | 338 ++++++++++-------- 1 file changed, 186 insertions(+), 152 deletions(-) diff --git a/src/main/resources/generator/client/vue/documentation/vue-jwt-authentication-components.md.mustache b/src/main/resources/generator/client/vue/documentation/vue-jwt-authentication-components.md.mustache index 6462084c26..eda0a6eba0 100644 --- a/src/main/resources/generator/client/vue/documentation/vue-jwt-authentication-components.md.mustache +++ b/src/main/resources/generator/client/vue/documentation/vue-jwt-authentication-components.md.mustache @@ -79,175 +79,175 @@ This file contains both the template and component logic for the authentication ``` @@ -548,13 +548,13 @@ export const stubAxiosInstance = (): AxiosStubInstance => { request: { use: sinon.stub(), eject: sinon.stub(), - clear: sinon.stub(), + clear: sinon.stub() }, response: { use: sinon.stub(), eject: sinon.stub(), - clear: sinon.stub(), - }, + clear: sinon.stub() + } }, runInterceptors: async (config: InternalAxiosRequestConfig) => { let currentConfig = { ...config, headers: config.headers || {} }; @@ -562,7 +562,7 @@ export const stubAxiosInstance = (): AxiosStubInstance => { currentConfig = await interceptor[0](currentConfig); } return currentConfig; - }, + } } as AxiosStubInstance; return instance; }; @@ -573,6 +573,40 @@ export const dataAxiosResponse = (data: T): AxiosResponse => }) as AxiosResponse; ``` +### 7. router.ts + +Location: `src/main/webapp/app/router.ts` + +This file sets up the main router for the application, including authentication routes. + +```typescript +import { authRoutes } from '@/auth/application/AuthRouter'; +import { homeRoutes } from '@/home/application/HomeRouter'; +import { createRouter, createWebHistory } from 'vue-router'; + +export const routes = [...homeRoutes(), ...authRoutes()]; + +const router = createRouter({ + history: createWebHistory(), + routes, +}); + +export default router; +``` + +### 8. main.ts + +Location: `src/main/webapp/app/main.ts` + +This files sets up the main application by configure the Axios interceptors. + +```typescript +// (ignoring previous code) ... +setupAxiosInterceptors(axiosInstance); +// jhipster-needle-main-ts-provider +app.mount('#app'); +``` + ## JHLite Backend Start the JHLite application and apply the `{{springBootJwtBasicAuthModule}}` module and the required dependencies.