nuxt-osdd
v1.0.5
Published
Package pour gérer l'OSDD (Operating System Dependency Design) dans Nuxt
Readme
nuxt-osdd
nuxt-osdd brings Open Source Driven Development to Nuxt. Organize your application into independent, composable layers — each layer with its own components, composables, pages, and configuration.
Why OSDD?
OSDD separates your application into two top-level buckets, keeping business logic and infrastructure concerns cleanly apart.
functional/
Domain layers that represent business concerns — functional/users, functional/orders, functional/billing. Each owns its own components, pages, composables, and assets.
technical/
Infrastructure layers shared across the application — authentication adapters, API clients, database configuration. Keeps cross-cutting concerns in one place.
Scalable by Design
Add new layers without touching existing ones. The architecture scales naturally from a small app to a large monorepo — no big-bang refactors required.
Simplified Structure
OSDD replaces Nuxt's default layers approach which adds unnecessary depth to your project structure.
Without OSDD (Nuxt default):
/layers/functional/<functionalLayer>/nuxt.config.tsWith OSDD:
/functional/<functionalLayer>/nuxt.config.ts
/technical/<technicalLayer>/nuxt.config.tsYour layers are directly at the project root, making your codebase flatter and easier to navigate.
Installation
npm install nuxt-osddFeatures
1. OSDD Layer Generation
Easily create functional or technical layers with pre-configured templates.
Usage
npx nuxt-osdd osdd:layer <layer-name> [--technical|--functional]
# Examples - Technical layers (infrastructure)
npx nuxt-osdd osdd:layer Authentication --technical
npx nuxt-osdd osdd:layer Database --technical
# Examples - Functional layers (business)
npx nuxt-osdd osdd:layer Contracts --functional
npx nuxt-osdd osdd:layer Posts --functional
# Interactive mode
npx nuxt-osdd osdd:layer
# Display help
npx nuxt-osdd --helpThe script will automatically create:
- A folder in
functional/ortechnical/at the project root - A basic
nuxt.config.tsfile - A
README.mdfile to document the layer
2. defineOSDDNuxtConfig
Wrap your nuxt.config.ts with defineOSDDNuxtConfig to declare OSDD layers. The osdd config key drives both extends and typescript.tsConfig automatically.
Usage
// nuxt.config.ts
import { defineOSDDNuxtConfig } from 'nuxt-osdd';
export default defineOSDDNuxtConfig({
osdd: {
technical: ['Authentication', 'Permission'], // Technical needs
functional: ['Contracts', 'Posts'], // Business needs
}
});Migration to OSDD
Migrating your existing Nuxt application to OSDD is straightforward:
- Update your main
nuxt.config.ts— simply replacedefineNuxtConfigwithdefineOSDDNuxtConfig:
// Before
import { defineNuxtConfig } from 'nuxt/config';
export default defineNuxtConfig({
// your config
});
// After
import { defineOSDDNuxtConfig } from 'nuxt-osdd';
export default defineOSDDNuxtConfig({
osdd: {
technical: ['Authentication', 'Database'],
functional: ['Users', 'Orders'],
},
// your config
});- Create your layers using the CLI command:
# Create technical layers
npx nuxt-osdd osdd:layer Authentication --technical
npx nuxt-osdd osdd:layer Database --technical
# Create functional layers
npx nuxt-osdd osdd:layer Users --functional
npx nuxt-osdd osdd:layer Orders --functional- Move your code into the appropriate layers (
functional/ortechnical/)
That's it! Your application is now organized with OSDD.
Import Paths
Disclaimer: If you don't use Nuxt's auto-import feature, you may need to update your import paths.
// Import from a functional layer
import { UserService } from '~/functional/Users/services/UserService';
// Import from a technical layer
import { AuthAdapter } from '~/technical/Authentication/adapters/AuthAdapter';License
ISC
