Skip to content

Référence des options

Cette page synthétise les options principales du bloc feathers dans nuxt.config.ts.

Exemple complet

ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    '@pinia/nuxt',
    'nuxt-feathers-zod',
  ],

  feathers: {
    servicesDirs: ['services'],

    client: {
      mode: 'embedded',
      pinia: true,
    },

    transports: {
      rest: {
        path: '/feathers',
        framework: 'express',
      },
      websocket: {
        path: '/socket.io',
        transports: ['websocket', 'polling'],
        connectTimeout: 45000,
      },
    },

    server: {
      enabled: true,
      framework: 'express',
      secureDefaults: true,
      modules: [],
    },

    database: {
      mongo: {
        url: 'mongodb://root:change-me@127.0.0.1:27017/app?authSource=admin',
        management: {
          enabled: false,
          basePath: '/mongo',
        },
      },
    },

    auth: false,
    keycloak: false,
    swagger: false,
    devtools: true,
    console: false,
  },
})

Options racine

OptionTypeDéfautDescription
servicesDirsstring | string[]['services']Dossiers scannés pour les services embedded
transportsobject{ websocket: true }REST et Socket.IO
serverobject | booleanserverDefaultsRuntime serveur embedded
clientobject | booleantrueClient Nuxt
authobject | booleantrueAuthentification Feathers
keycloakobject | booleanfalseSSO Keycloak côté client
databaseobject{}Infrastructure base de données
validatorobject{ formats: [], extendDefaults: true }Validateurs Zod/AJV
swaggerobject | booleanfalseSwagger legacy
templatesobject{}Overrides de templates
devtoolsbooleantrueDevTools NFZ en développement
consoleobject | booleanfalseConsole/builder NFZ

client

ts
client: {
  mode: 'embedded',
  pinia: true,
}
OptionTypeDescription
mode'embedded' | 'remote'Mode d’exécution client
piniaboolean | objectActive les stores runtime NFZ
remote.urlstringURL de l’API Feathers distante
remote.transport'auto' | 'rest' | 'socketio'Transport remote
remote.restPathstringChemin REST distant
remote.websocketPathstringChemin Socket.IO distant
remote.servicesArray<{ path, methods? }>Services distants déclarés
remote.authobjectAuthentification remote

remote.auth

ts
client: {
  mode: 'remote',
  remote: {
    url: 'https://api.example.com',
    auth: {
      enabled: true,
      payloadMode: 'keycloak',
      strategy: 'jwt',
      tokenField: 'access_token',
      servicePath: 'authentication',
      reauth: true,
      storageKey: 'feathers-jwt',
    },
  },
}
OptionDescription
enabledActive l’auth remote
payloadModejwt ou keycloak
strategyStratégie Feathers envoyée
tokenFieldChamp du token dans le payload
servicePathService d’authentification
reauthRéauthentification automatique
storageKeyClé de stockage du token

transports

ts
transports: {
  rest: {
    path: '/feathers',
    framework: 'express',
  },
  websocket: {
    path: '/socket.io',
  },
}
OptionDescription
restConfiguration REST ou false
rest.pathPréfixe REST
rest.frameworkexpress ou koa
websocketConfiguration Socket.IO ou false
websocket.pathChemin Socket.IO
websocket.transportsTransports Socket.IO
websocket.connectTimeoutTimeout de connexion
websocket.corsCORS Socket.IO

server

ts
server: {
  enabled: true,
  framework: 'express',
  secureDefaults: true,
}
OptionDescription
enabledActive le runtime serveur embedded
frameworkexpress ou koa
secureDefaultsActive un preset sécurisé
modulesModules serveur personnalisés
modulesDirDossier des modules serveur
serveStaticSert des fichiers statiques
serveStaticPathChemin public
serveStaticDirDossier local

auth

ts
auth: {
  service: 'users',
  entity: 'user',
  entityClass: 'User',
  authStrategies: ['local', 'jwt'],
  local: {
    usernameField: 'email',
    passwordField: 'password',
  },
}
OptionDescription
serviceService utilisateur
entityNom de l’entité
entityClassClasse/type d’entité
authStrategieslocal, jwt, oauth
jwtOptionsOptions JWT Feathers
localOptions local auth
client.storageKeyClé de stockage côté client

database.mongo

ts
database: {
  mongo: {
    url: 'mongodb://root:change-me@127.0.0.1:27017/app?authSource=admin',
    management: {
      enabled: true,
      basePath: '/mongo',
      auth: true,
    },
  },
}
OptionDescription
urlURL MongoDB
management.enabledActive les routes management
management.basePathBase path management
management.authProtection des routes
management.exposeDatabasesServiceExpose les bases
management.exposeCollectionsServiceExpose les collections
management.exposeCollectionCrudExpose documents/aggregate
management.whitelistDatabasesAllowlist bases
management.blacklistDatabasesBlocklist bases
management.whitelistCollectionsAllowlist collections
management.blacklistCollectionsBlocklist collections
management.allowCreateDatabaseCréation de base
management.allowDropDatabaseSuppression de base
management.allowCreateCollectionCréation de collection
management.allowDropCollectionSuppression de collection
management.allowInsertDocumentsInsert documents
management.allowPatchDocumentsPatch documents
management.allowReplaceDocumentsReplace documents
management.allowRemoveDocumentsDelete documents

keycloak

ts
keycloak: {
  serverUrl: 'https://sso.example.com',
  realm: 'myrealm',
  clientId: 'my-nuxt-app',
  onLoad: 'check-sso',
}
OptionDescription
serverUrlURL Keycloak
realmRealm
clientIdClient public
authServicePathService d’auth côté Feathers
onLoadcheck-sso ou login-required

templates

ts
templates: {
  dirs: ['feathers/templates'],
}

Les templates permettent de remplacer les fichiers générés dans .nuxt/feathers.

Bonnes pratiques

  • Garde les options explicites dans les projets de production.
  • Active auth: false pendant les premiers tests si aucun service users n’existe.
  • Active database.mongo.management.auth dès que les routes Mongo sont exposées.
  • En remote, configure server.enabled: false pour éviter toute ambiguïté.
  • Documente les overrides de templates dans ton README applicatif.

Documentation du module nuxt-feathers-zod