0.1.2 • Published 2 years ago
nuxt-vine v0.1.2
Nuxt Vine
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
- Add
nuxt-vinedependency 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- Add
nuxt-vineto themodulessection ofnuxt.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:
validateBodyto validate the body of a requestvalidateQueryto validate the query of a requestvalidateParamsto 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 releaseThanks Atinux for the initial works!