0.1.2 • Published 11 months ago

nuxt-vine v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Nuxt Vine

npm version npm downloads License Nuxt

A module to easily use VineJS in Nuxt for for server-side validation!

Features

  • 📦 Easy Setup: Just add the module to your Nuxt config and you're good to go!
  • 🪄 Automatic error handling: Errors are automatically handled when a validation fails.

Quick Setup

  1. Add nuxt-vine dependency to your project
# Using pnpm
pnpm add -D nuxt-vine

# Using yarn
yarn add --dev nuxt-vine

# Using npm
npm install --save-dev nuxt-vine
  1. Add nuxt-vine to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'nuxt-vine'
  ]
})

That's it! You can now use Nuxt Vine in your Nuxt app ✨

Usage

This plugin automatically imports composable functions into your Nitro routes.

Validation

export default defineEventHandler(async (event) => {
  const { title } = await validateBody(event, {
    title: v.string()
  })

  // If validation failed, an error will be thrown and handled by this package.

  return title
})

v is an alias for vine.

You can use:

  • validateBody to validate the body of a request
  • validateQuery to validate the query of a request
  • validateParams to validate the params of a request

Development

# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release

Thanks Atinux for the initial works!

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago