Skip to content

Commit 67770f5

Browse files
committed
chore: trying asyncData and serverMiddleware apis
1 parent 20284ee commit 67770f5

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

nuxt.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export default {
107107
sitemap: {
108108
hostname: BASE_URL
109109
},
110+
110111
// Build Configuration: https://go.nuxtjs.dev/config-build
111112
build: {
112113
extractCSS: true,
@@ -115,5 +116,9 @@ export default {
115116
config.devtool = 'source-map'
116117
}
117118
}
118-
}
119+
},
120+
121+
serverMiddleware: [
122+
{ path: '/test', handler: '~/serverMiddleware/ok.js' },
123+
]
119124
}

pages/diff.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<div
5353
class="flex items-stretch w-full gap-4 font-mono text-gray-800 dark:text-gray-50"
5454
>
55+
<h1>{{ name }}</h1>
5556
<div
5657
class="relative flex-1 px-4 py-2 overflow-y-auto border-2 rounded-md dark:border-gray-500 max-h-screen--nav line-number-gutter min-h-80"
5758
>
@@ -97,6 +98,9 @@ export default {
9798
copied: false,
9899
}
99100
},
101+
asyncData() {
102+
return { name: 'World' }
103+
},
100104
mounted() {
101105
const _diff = this.$route.hash
102106
const gunzip = pako.ungzip(Buffer.from(undoUrlSafeBase64(_diff), 'base64'))

serverMiddleware/ok.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function handler(_req, res) {
2+
res.end('Everything ok!')
3+
}

0 commit comments

Comments
 (0)