Setup
- In your nuxt application, install the npm package:
bash
npm i nuxt-nust- Add
nuxt-nustto list of modules in yournuxt.config.tsfile, along with thenustconfigurations:
typescript
// nuxt.config.ts
export default defineNuxtConfig({
modules: [
'nuxt-nust'
],
nust: {
controllersFile: '~/server/nust/index.ts', // Path to controllers export file in your project relative to root folder
debug: false, // Enable to show the routes added by your controllers in the logs
}
})- Create a file in your project to export all controllers that sits under the path specified in the previous step, for example:
server/nust/index.ts
typescript
// server/nust/index.ts
import { type NustControllers } from '#nust'
export default {
// Here you'll be adding your controller classes
// Example:
// post: PostController
} satisfies NustControllers- Update the
tsconfig.jsonfiles by adding the following lines:
json
{
"extends": "../.nuxt/tsconfig.server.json",
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictPropertyInitialization": false
}
}- That's it! You can now use the Nust Module in your Nuxt app ✨