Skip to content

Commit 048a7ca

Browse files
committed
chore(core): upgrade nuxt3 stable, typing
1 parent 835872a commit 048a7ca

File tree

19 files changed

+1656
-1725
lines changed

19 files changed

+1656
-1725
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
Authenticated server-side rendering with Nuxt 3 and Auth0 API server middleware
44

5+
![Screenshot](assets/custom-server-authentication.png)
6+
57
## Features
6-
- [💚 Nuxt 3](https://v3.nuxtjs.org) - SSR, ESR, File-based routing, components auto importing, modules, etc. Are you new in Nuxt3? We recommend to look at the [documentation](https://v3.nuxtjs.org/docs).
8+
- [💚 Nuxt 3](https://nuxt.com) - SSR, ESR, File-based routing, components auto importing, modules, etc. Are you new in Nuxt3? We recommend to look at the [documentation](https://nuxt.com/docs).
79

810
- 🔥 The `<script setup>` syntax
911

10-
- 🚠 Auth0 SDK Authentication services
12+
- 🚠 Auth0 SDK Authentication services. Auth0 Federated Identity Management.
1113

12-
- :lock: Hapi iron module for encapsulated tokens on Cookies
14+
- Hapi iron module for encapsulated tokens on Cookies
1315

1416
- 🚀 The PrimeVue for styled components
1517

@@ -25,6 +27,12 @@ We recommend using [VS Code](https://code.visualstudio.com/) with [Volar](https:
2527
First of all, you need to create Auth0 acount and SDK setup.
2628
https://auth0.com/docs/quickstart/spa/vanillajs
2729

30+
You need to create `.env` file with this content from Auth0 project (security credentials should never be shared):
31+
```bash
32+
cp .env.example .env
33+
```
34+
35+
2836
## Setup
2937

3038
Make sure to install the dependencies
@@ -51,10 +59,10 @@ Build the application for production:
5159
yarn build
5260
```
5361

54-
Checkout the [deployment documentation](https://v3.nuxtjs.org/docs/deployment).
62+
Checkout the [deployment documentation](https://nuxt.com/docs/getting-started/deployment).
5563

5664
## References
57-
- We recommend to look at the [Nuxt3](https://v3.nuxtjs.org).
65+
- We recommend to look at the [Nuxt3](https://nuxt.com).
5866
- [Auth0 API](https://auth0.com/docs/api/authentication)
5967
- [Primevue](https://www.primefaces.org/primevue/#/)
6068
- [Hapi Iron](https://hapi.dev/module/iron/)
16.2 KB
Loading

layouts/default.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div>
33
<div class="grid">
44
<div class="col-12">
5-
<Menubar :model="items" >
5+
<Menubar :model="items">
66
<template #start>
77
<img
88
alt="logo"
@@ -14,8 +14,7 @@
1414
<template #end>
1515
<div v-if="user">
1616
<span class="m-2">
17-
Welcome, <a href="/api/auth/me">{{ user.nickname }}</a> |
18-
<a href="/api/auth/logout">Logout</a>
17+
Welcome, {{ user.nickname }} | <a href="/api/auth/logout">Logout</a>
1918
</span>
2019
<Avatar :image="user.picture" shape="circle" />
2120
</div>
@@ -24,7 +23,7 @@
2423
</div>
2524
</template>
2625
</Menubar>
27-
<Panel :header="route.name.toString()">
26+
<Panel :header="route.name?.toString()">
2827
<slot />
2928
</Panel>
3029
</div>
@@ -40,18 +39,18 @@ const items = [
4039
{
4140
label: 'Home',
4241
icon: 'pi pi-fw pi-home',
43-
to: '/',
42+
to: '/'
4443
},
4544
{
4645
label: 'About',
4746
icon: 'pi pi-fw pi-file',
48-
to: '/about',
47+
to: '/about'
4948
},
5049
{
5150
label: 'Profile',
5251
icon: 'pi pi-fw pi-user',
5352
to: '/profile',
5453
visible: user.value != null
55-
},
54+
}
5655
]
5756
</script>

middleware/watchdog.global.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import useUser from "~~/composables/useUser";
2+
3+
export default defineNuxtRouteMiddleware((to, from) => {
4+
const user = useUser()
5+
const allowedRoutes = ['/', '/login']
6+
if (user.value) {
7+
if (allowedRoutes.includes(to.path)) {
8+
return navigateTo('/private')
9+
}
10+
} else {
11+
if (!allowedRoutes.includes(to.path)) {
12+
return navigateTo('/login')
13+
}
14+
}
15+
})

models/Meme.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export type Meme = {
2+
id: string
3+
name: string
4+
url: string
5+
width: number
6+
height: number
7+
}
8+
9+
export type MemeResponse = {
10+
success: boolean
11+
data: {
12+
memes: Meme[]
13+
}
14+
}

nuxt.config.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const {
77
AUTH0_COOKIE_NAME
88
} = process.env;
99

10-
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
1110
export default defineNuxtConfig({
1211
app: {
1312
head: {
@@ -47,9 +46,5 @@ export default defineNuxtConfig({
4746
"primevue/resources/primevue.css",
4847
"primeicons/primeicons.css",
4948
"primeflex/primeflex.css"
50-
],
51-
components: {
52-
global: true,
53-
dirs: ["~/components"]
54-
}
49+
]
5550
});

0 commit comments

Comments
 (0)