Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nuxt-config-schema

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-config-schema

This is a proof of concept module for a feature in Nuxt 3 that automatically infers and generates schema based on user provided configuration from several sources using [unjs/untyped](https://github.com/unjs/untyped) and supports extending layers.

  • 0.4.3
  • npm
  • Socket score

Version published
Weekly downloads
3.7K
decreased by-37.28%
Maintainers
1
Weekly downloads
 
Created
Source

Nuxt Config Schema

This is a proof of concept module for a feature in Nuxt 3 that automatically infers and generates schema based on user provided configuration from several sources using unjs/untyped and supports extending layers.

Schema can be defined in nuxt.schema.ts or $schema field in nuxt.config.ts.

Read the proposal for Nuxt 3

This experiment is landed to Nuxt 3 core since 3.1.0 (https://github.com/nuxt/nuxt/pull/18410)

Usage

  1. Install nuxt-config-schema as dev dependency:
# npm
npm i -D nuxt-config-schema

# pnpm
pnpm add -D nuxt-config-schema

# yarn
yarn add nuxt-config-schema
  1. Add module to nuxt.config:
export default defineNuxtConfig({
  modules: ['nuxt-config-schema'],
})
  1. Create nuxt.schema.ts:
export default defineNuxtConfigSchema({
  appConfig: {
    test2: {
      $default: 'from nuxt.schema',
    },
  },
  /** Config schema for another integration */
  anotherConfig: {
    aTest: '123',
  },
})
  1. Use nuxi dev or nuxi build commands

You can access generated schema (json, markdown and types) from .nuxt/schema/ directory and also hooks below:

  • schema:extend(schemaDefs): Extend schema defenitions (first call after modules:done hook)
  • schema:resolved(schema): Extend resolved schema after merging (first call after modules:done hook)
  • schema:beforeWrite(schema): Extend resolved schema just before writing to filesystem (called after build:done hook)
  • schema:written: Hook will be called when schema has been written and updated to filesystem

Development

  • Run npm run dev:prepare to generate type stubs.
  • Use npm run dev to start playground in development mode.

FAQs

Package last updated on 23 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc