File tree Expand file tree Collapse file tree 28 files changed +190
-1138
lines changed Expand file tree Collapse file tree 28 files changed +190
-1138
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module.exports = {
3
3
root : true ,
4
4
extends : [
5
5
"@nuxt/eslint-config" ,
6
+ 'plugin:prettier/recommended'
6
7
// "plugin:vue/vue3-recommended"
7
8
] ,
8
9
rules : {
Original file line number Diff line number Diff line change 1
1
// https://nuxt.com/docs/api/configuration/nuxt-config
2
2
export default defineNuxtConfig ( {
3
- srcDir : 'src/' ,
4
- modules : [
5
- '@pinia/nuxt'
6
- ] ,
3
+ srcDir : "src/" ,
4
+ modules : [ "@pinia/nuxt" ] ,
7
5
runtimeConfig : {
8
- API_URL : process . env . API_URL || ''
6
+ API_URL : process . env . API_URL || "" ,
9
7
} ,
10
8
app : {
11
-
12
9
head : {
13
10
// @see https://getbootstrap.com/docs/5.0/getting-started/introduction/#starter-template
14
- charset : ' utf-8' ,
15
- viewport : ' width=device-width, initial-scale=1' ,
16
- title : ' KB Backbone' ,
11
+ charset : " utf-8" ,
12
+ viewport : " width=device-width, initial-scale=1" ,
13
+ title : " KB Backbone" ,
17
14
meta : [
18
15
// <meta name="description" content="My amazing site">
19
16
// { name: 'description', content: 'My amazing site.' }
20
- ]
21
- }
17
+ ] ,
18
+ } ,
22
19
} ,
23
- css : [
24
- '@/assets/styles/main.scss'
25
- ] ,
20
+ css : [ "@/assets/styles/main.scss" ] ,
26
21
vite : {
27
22
css : {
28
23
preprocessorOptions : {
29
24
scss : {
30
- additionalData : '@import "@/assets/styles/_functions.scss";@import "@/assets/styles/_variables.scss";@import "@/assets/styles/_mixins.scss";'
31
- }
32
- }
33
- }
34
- }
25
+ additionalData :
26
+ '@import "@/assets/styles/_functions.scss";@import "@/assets/styles/_variables.scss";@import "@/assets/styles/_mixins.scss";' ,
27
+ } ,
28
+ } ,
29
+ } ,
30
+ } ,
35
31
// ssr: false
36
-
37
32
} ) ;
Original file line number Diff line number Diff line change 14
14
"@rushstack/eslint-patch" : " ^1.3.0" ,
15
15
"@types/http-proxy" : " ^1.17.11" ,
16
16
"@types/lodash" : " ^4.14.195" ,
17
- "@typescript-eslint/eslint-plugin" : " ^5.59.7" ,
18
17
"eslint" : " ^8.41.0" ,
18
+ "eslint-config-prettier" : " ^8.8.0" ,
19
+ "eslint-plugin-prettier" : " ^4.2.1" ,
19
20
"pino-pretty" : " ^10.0.0" ,
20
21
"typescript" : " ^5.0.4" ,
21
22
"vue-tsc" : " ^1.6.5"
22
23
},
23
24
"dependencies" : {
24
- "@nuxtjs/eslint-config-typescript" : " ^12.0.0" ,
25
25
"bootstrap" : " ^5.2.3" ,
26
26
"defu" : " ^6.1.2" ,
27
27
"h3" : " ^1.6.6" ,
Original file line number Diff line number Diff line change 8
8
</div >
9
9
</template >
10
10
<script setup lang="ts">
11
- import { watchEffect } from ' vue' ;
12
- import { useAuthUser } from ' ~/store/auth' ;
11
+ import { watchEffect } from " vue" ;
12
+ import { useAuthUser } from " ~/store/auth" ;
13
13
14
14
const authStore = useAuthUser ();
15
15
16
16
const route = useRoute ();
17
17
18
18
const mHandleError = (e : unknown ) => {
19
- logger .error (' Primary error boundary' , e );
19
+ logger .error (" Primary error boundary" , e );
20
20
};
21
21
const isPendingValue = computed (() => authStore .isPending );
22
22
// Doing this here instead than in the middleware allow reactivity on the auth user
23
23
watchEffect (async () => {
24
24
if (isPendingValue .value ) {
25
25
return ;
26
26
}
27
- const shouldRedirectToLogin = ! authStore .isAuthenticated && authStore .authUrl && route .name !== ' auth-login' ;
27
+ const shouldRedirectToLogin =
28
+ ! authStore .isAuthenticated &&
29
+ authStore .authUrl &&
30
+ route .name !== " auth-login" ;
28
31
if (shouldRedirectToLogin ) {
29
32
await navigateTo (authStore .authUrl , { external: true });
30
33
}
31
- const shouldRedirectToHomepage = authStore .isAuthenticated && route .name === ' auth-login' ;
34
+ const shouldRedirectToHomepage =
35
+ authStore .isAuthenticated && route .name === " auth-login" ;
32
36
if (shouldRedirectToHomepage ) {
33
- await navigateTo (' / ' );
37
+ await navigateTo (" / " );
34
38
}
35
39
});
36
40
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" row justify-content-end py-2 mb-2" >
3
3
<div class =" col-2" >
4
- <p v-if =" username" >
5
- Welcome {{ username }}
6
- </p >
4
+ <p v-if =" username" >Welcome {{ username }}</p >
7
5
</div >
8
6
</div >
9
7
</template >
10
8
<script setup lang="ts">
11
9
// import {} from "s"
12
- import { useAuthUser } from ' ~/store/auth' ;
10
+ import { useAuthUser } from " ~/store/auth" ;
13
11
14
12
const authStore = useAuthUser ();
15
13
16
- const username = authStore .authUser ?.username || ' ' ;
14
+ const username = authStore .authUser ?.username || " " ;
17
15
</script >
Original file line number Diff line number Diff line change 2
2
<div
3
3
class =" d-flex flex-sm-column flex-row flex-nowrap bg-light align-items-center sticky-top"
4
4
>
5
- <NuxtLink
6
- to =" /"
7
- class =" d-block p-3 link-dark text-decoration-none"
8
- >
5
+ <NuxtLink to =" /" class =" d-block p-3 link-dark text-decoration-none" >
9
6
<icons1-square-fill />
10
7
</NuxtLink >
11
8
<ul
37
34
<script setup lang="ts">
38
35
// Credit to https://dev.to/codeply/bootstrap-5-sidebar-examples-38pb
39
36
// Another interesting ressource https://www.codeply.com/p/yE87h7irNi/icons-text
40
- import MenuItem from ' ./MenuItem.vue' ;
37
+ import MenuItem from " ./MenuItem.vue" ;
41
38
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<li class =" nav-item" >
3
- <NuxtLink
4
- v-bind =" $attrs"
5
- class =" nav-link py-3 px-2"
6
- >
3
+ <NuxtLink v-bind =" $attrs" class =" nav-link py-3 px-2" >
7
4
<slot />
8
5
</NuxtLink >
9
6
</li >
Original file line number Diff line number Diff line change 1
- import { Me } from ' ./useMe' ;
1
+ import { Me } from " ./useMe" ;
2
2
3
- export default function useLogin ( ) : ( email : string , password : string | undefined ) => Promise < Me > {
3
+ export default function useLogin ( ) : (
4
+ email : string ,
5
+ password : string | undefined
6
+ ) => Promise < Me > {
4
7
const { $appFetch } = useNuxtApp ( ) ;
5
8
return async ( email : string , password : string | undefined ) => {
6
- const response = await $appFetch < Me > ( ' /api/1.0/auth/sso/saml2/login' , {
7
- method : ' post' ,
9
+ const response = await $appFetch < Me > ( " /api/1.0/auth/sso/saml2/login" , {
10
+ method : " post" ,
8
11
body : {
9
12
username : email ,
10
- password
11
- }
13
+ password,
14
+ } ,
12
15
} ) ;
13
16
if ( ! response ) {
14
- throw createError ( '/api/1.0/auth/sso/saml2/login has an empty body, the profile (me) should be returned' ) ;
17
+ throw createError (
18
+ "/api/1.0/auth/sso/saml2/login has an empty body, the profile (me) should be returned"
19
+ ) ;
15
20
}
16
21
return response ;
17
22
} ;
Original file line number Diff line number Diff line change @@ -2,12 +2,12 @@ export interface Me {
2
2
username : string ;
3
3
}
4
4
5
- export default function useMe ( ) : ( ) => Promise < Me > {
5
+ export default function useMe ( ) : ( ) => Promise < Me > {
6
6
const { $appFetch } = useNuxtApp ( ) ;
7
7
return async ( ) => {
8
- const res = await $appFetch < Me > ( ' /api/1.0/auth/me' ) ;
8
+ const res = await $appFetch < Me > ( " /api/1.0/auth/me" ) ;
9
9
if ( ! res ) {
10
- throw createError ( ' /api/1.0/auth/me has an empty body' ) ;
10
+ throw createError ( " /api/1.0/auth/me has an empty body" ) ;
11
11
}
12
12
return res ;
13
13
} ;
Original file line number Diff line number Diff line change 1
- import { FetchError } from ' ofetch' ;
2
- import { AsyncData } from ' #app' ;
3
- import useAppFetch from ' ~/composables/useAppFetch' ;
1
+ import { FetchError } from " ofetch" ;
2
+ import { AsyncData } from " #app" ;
3
+ import useAppFetch from " ~/composables/useAppFetch" ;
4
4
5
5
interface LoggedHealthCheckResponse {
6
- success : string
6
+ success : string ;
7
7
}
8
- export function useHealthCheckFetch ( ) : AsyncData < LoggedHealthCheckResponse | null , FetchError | null > {
8
+ export function useHealthCheckFetch ( ) : AsyncData <
9
+ LoggedHealthCheckResponse | null ,
10
+ FetchError | null
11
+ > {
9
12
return useAppFetch < LoggedHealthCheckResponse > (
10
- ( ) => ' /api/1.0/healthcheck/logged'
13
+ ( ) => " /api/1.0/healthcheck/logged"
11
14
) ;
12
15
}
Original file line number Diff line number Diff line change 1
- import type { UseFetchOptions } from ' nuxt/app' ;
2
- import { defu } from ' defu' ;
3
- import { $Fetch , NitroFetchRequest } from ' nitropack' ;
1
+ import type { UseFetchOptions } from " nuxt/app" ;
2
+ import { defu } from " defu" ;
3
+ import { $Fetch , NitroFetchRequest } from " nitropack" ;
4
4
5
- export default function useAppFetch < T > ( url : string | Request | Ref < string | Request > | ( ( ) => string | Request ) , options : UseFetchOptions < T > = { } ) {
5
+ export default function useAppFetch < T > (
6
+ url : string | Request | Ref < string | Request > | ( ( ) => string | Request ) ,
7
+ options : UseFetchOptions < T > = { }
8
+ ) {
6
9
const { $appFetch } = useNuxtApp ( ) ;
7
10
const defaults : UseFetchOptions < T > = {
8
- $fetch : $appFetch as $Fetch < unknown , NitroFetchRequest >
11
+ $fetch : $appFetch as $Fetch < unknown , NitroFetchRequest > ,
9
12
} ;
10
13
11
14
// for nice deep defaults, please use unjs/defu
Original file line number Diff line number Diff line change 2
2
<div >
3
3
<slot />
4
4
</div >
5
- </template >;
5
+ </template >
6
+ ;
Original file line number Diff line number Diff line change 14
14
</div >
15
15
</div >
16
16
</div >
17
- </template >;
17
+ </template >
18
+ ;
Original file line number Diff line number Diff line change 1
- import { useAuthUser } from ' ~/store/auth' ;
1
+ import { useAuthUser } from " ~/store/auth" ;
2
2
3
3
export default defineNuxtRouteMiddleware ( async ( ) => {
4
4
const authStore = useAuthUser ( ) ;
@@ -13,7 +13,8 @@ export default defineNuxtRouteMiddleware(async () => {
13
13
* If we want to speed up a bit the process, we could check the status of the syncMe request,
14
14
* to know if it has been done once aka if (authStore.hasBeenLoadedOnce)
15
15
* */
16
- const shouldWait = process . server || ( ! authStore . isAuthenticated && process . client ) ;
16
+ const shouldWait =
17
+ process . server || ( ! authStore . isAuthenticated && process . client ) ;
17
18
if ( ! shouldWait ) {
18
19
return ;
19
20
}
Original file line number Diff line number Diff line change 2
2
<div >
3
3
<div v-if =" !authStore.isAuthenticated" >
4
4
<h1 >Welcome to the login page</h1 >
5
- <label for =" email" >
6
- email
7
- </label >
8
- <input
9
- v-model =" email"
10
- name =" email"
11
- type =" text"
12
- >
13
- <button
14
- type =" submit"
15
- @click =" submitAuthenticateUser"
16
- >
17
- Log-in
18
- </button >
5
+ <label for =" email" > email </label >
6
+ <input v-model =" email" name =" email" type =" text" />
7
+ <button type =" submit" @click =" submitAuthenticateUser" >Log-in</button >
19
8
</div >
20
9
</div >
21
10
</template >
22
11
<script setup lang="ts">
23
- import { ref } from ' vue' ;
24
- import { useAuthUser } from ' ~/store/auth' ;
12
+ import { ref } from " vue" ;
13
+ import { useAuthUser } from " ~/store/auth" ;
25
14
26
15
definePageMeta ({
27
- layout: ' anonymous'
16
+ layout: " anonymous" ,
28
17
});
29
18
30
19
const authStore = useAuthUser ();
@@ -38,8 +27,8 @@ const authStore = useAuthUser();
38
27
* It only becomes an issue when your ref relies on state from the server,
39
28
* such as a header from the request, or data fetched during the server-rendering process.
40
29
* * */
41
- const email = ref (' user@kb.com' );
30
+ const email = ref (" user@kb.com" );
42
31
const submitAuthenticateUser = async () => {
43
- await authStore .authenticateUser (email .value , ' ' );
32
+ await authStore .authenticateUser (email .value , " " );
44
33
};
45
34
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
3
Page 1
4
- <img
5
- src =" ~/assets/images/panda.webp"
6
- alt =" Discover Pandas"
7
- >
8
- <div class =" panda-background" >
9
- This is to discover background scss
10
- </div >
4
+ <img src =" ~/assets/images/panda.webp" alt =" Discover Pandas" />
5
+ <div class =" panda-background" >This is to discover background scss</div >
11
6
</div >
12
7
</template >
13
8
<script lang="ts" setup>
14
- logger .info (' page 1' );
9
+ logger .info (" page 1" );
15
10
</script >
16
11
<style lang="scss" scoped>
17
12
.panda-background {
18
13
color : $white ;
19
14
width : 200px ;
20
15
height : 200px ;
21
- background-image : url (' ~/assets/images/true-panda.jpeg' );
16
+ background-image : url (" ~/assets/images/true-panda.jpeg" );
22
17
background-size : contain ;
23
18
background-repeat : no-repeat ;
24
19
}
Original file line number Diff line number Diff line change 7
7
</div >
8
8
</template >
9
9
<script lang="ts" setup>
10
- import { useHealthCheckFetch } from ' ~/composables/api/healthCheck/useHealthCheckFetch' ;
10
+ import { useHealthCheckFetch } from " ~/composables/api/healthCheck/useHealthCheckFetch" ;
11
11
12
- const {
13
- data
14
- } = await useHealthCheckFetch ();
12
+ const { data } = await useHealthCheckFetch ();
15
13
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >Page 3</div >
3
- </template >;
3
+ </template >
4
+ ;
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >Page 4</div >
3
- </template >;
3
+ </template >
4
+ ;
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >Page 5</div >
3
- </template >;
3
+ </template >
4
+ ;
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >Page 6</div >
3
- </template >;
3
+ </template >
4
+ ;
You can’t perform that action at this time.
0 commit comments