secondsky/claude-skills / plugins/nuxt-v5/skills/nuxt-server
nuxt-server
VerifiedNuxt 5 server-side development with Nitro v3, h3 v2, API routes, middleware, and database integration. Use when creating server routes, integrating D1/Drizzle, or migrating from Nitro v2.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.3 KB |
| references/server.md | markdown | 13.4 KB |
| templates/server/api/blog/index.get.ts | script | 1.5 KB |
templates/server/api/blog/index.get.ts
View on GitHubimport { defineEventHandler, getQuery } from 'h3'
import { useDB } from '~/server/db'
import { posts } from '~/server/db/schema'
import { eq, desc, sql } from 'drizzle-orm'
// GET /api/blog - List all blog posts
export default defineEventHandler(async (event) => {
const query = getQuery(event)
// Validate and sanitize query parameters
const pageNum = Number(query.page)
const page = Number.isInteger(pageNum) && pageNum >= 1 ? pageNum : 1
const limitNum = Number(query.limit)
const limit = Number.isInteger(limitNum) && limitNum >= 1 && limitNum <= 100 ? limitNum : 10
// Sanitize category - allow only alphanumeric, hyphens, and underscores
let category: string | undefined
if (query.category && typeof query.category === 'string') {
const sanitized = query.category.trim().replace(/[^a-zA-Z0-9-_]/g, '')
category = sanitized.length > 0 && sanitized.length <= 50 ? sanitized : undefined
}
const db = useDB(event)
// Build query
let dbQuery = db.select().from(posts)
// Filter by category
if (category) {
dbQuery = dbQuery.where(eq(posts.category, category))
}
// Pagination
const allPosts = await dbQuery
.orderBy(desc(posts.createdAt))
.limit(limit)
.offset((page - 1) * limit)
// Get total count
const [{ count }] = await db
.select({ count: sql`count(*)` })
.from(posts)
.where(category ? eq(posts.category, category) : undefined)
return {
data: allPosts,
meta: {
page,
limit,
total: Number(count),
totalPages: Math.ceil(Number(count) / limit)
}
}
})
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |