Nuxt/test/fixtures/basic/modules/example.ts

24 lines
620 B
TypeScript
Raw Normal View History

import { fileURLToPath } from 'node:url'
import { defineNuxtModule, addPlugin, useNuxt } from '@nuxt/kit'
export default defineNuxtModule({
defaults: {
enabled: true,
typeTest: (value: boolean) => typeof value === 'boolean'
},
meta: {
name: 'my-module',
configKey: 'sampleModule'
},
setup () {
addPlugin(fileURLToPath(new URL('./runtime/plugin', import.meta.url)))
useNuxt().hook('app:resolve', (app) => {
app.middleware.push({
name: 'unctx-test',
path: fileURLToPath(new URL('./runtime/middleware', import.meta.url)),
global: true
})
})
}
})