npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fastify-ata

v0.2.14

Published

Fastify plugin for ata-validator — beats ajv on every valid-path benchmark. 2.7x faster validate(obj), 151x faster compilation, simdjson + multi-core.

Downloads

1,227

Readme

fastify-ata

Fastify plugin for ata-validator - JSON Schema validation powered by simdjson.

Drop-in replacement for Fastify's default ajv validator. Standard Schema V1 compatible.

Install

npm install fastify-ata

Usage

const fastify = require('fastify')()
const fastifyAta = require('fastify-ata')

fastify.register(fastifyAta)

fastify.post('/user', {
  schema: {
    body: {
      type: 'object',
      properties: {
        name: { type: 'string', minLength: 1 },
        age: { type: 'integer', minimum: 0 },
        role: { type: 'string', default: 'user' }
      },
      required: ['name']
    }
  }
}, (req, reply) => {
  // req.body.role === 'user' (default applied)
  reply.send({ ok: true, name: req.body.name })
})

fastify.listen({ port: 3000 })

All your existing JSON Schema route definitions work as-is.

Options

fastify.register(fastifyAta, {
  coerceTypes: true,       // convert "42" → 42 for integer fields
  removeAdditional: true,  // strip properties not in schema
})

Standalone Mode (Pre-compiled)

Drop-in replacement for @fastify/ajv-compiler/standalone. Same API.

const StandaloneValidator = require('fastify-ata/standalone')

// Build phase (once) - compile schemas to JS files
const app = fastify({
  schemaController: { compilersFactory: {
    buildValidator: StandaloneValidator({
      readMode: false,
      storeFunction(routeOpts, code) {
        fs.writeFileSync(generateFileName(routeOpts), code)
      }
    })
  }}
})

// Read phase (every startup) - load pre-compiled, near-zero compile time
const app = fastify({
  schemaController: { compilersFactory: {
    buildValidator: StandaloneValidator({
      readMode: true,
      restoreFunction(routeOpts) {
        return require(generateFileName(routeOpts))
      }
    })
  }}
})

Standard Schema V1

ata-validator natively implements Standard Schema V1 - the emerging standard for TypeScript-first schema libraries.

const { Validator } = require('ata-validator')
const v = new Validator(schema)

// Standard Schema V1 interface
const result = v['~standard'].validate(data)
// { value: data } on success
// { issues: [{ message, path }] } on failure

Works with Fastify v5's Standard Schema support, tRPC, TanStack Form, Drizzle ORM.

What it does

  • Registers a custom validatorCompiler using ata-validator
  • Applies default values, coerceTypes, removeAdditional during validation
  • Caches compiled schemas (WeakMap) for reuse across routes
  • Returns Fastify-compatible validation errors on invalid requests (400)
  • Works with Fastify v4 and v5

Performance

Real-world HTTP benchmark (autocannon, 10 connections, 5s)

| Payload | ata | ajv | | |---|---|---|---| | 1 user (0.1KB) | 65.7K req/sec | 65.7K req/sec | equal | | 10 users (0.9KB) | 57.2K | 55.3K | +3% | | 50 users (4.6KB) | 36.0K | 33.8K | +6% | | 100 users (9.1KB) | 24.6K | 22.6K | +9% |

Where ata really shines

| Scenario | ata | ajv | | |---|---|---|---| | Serverless cold start (50 schemas) | 7.7ms | 96ms | 12.5x faster | | ReDoS protection (catastrophic pattern) | 0.3ms | 765ms | immune | | Batch NDJSON (10K items, multi-core) | 13.4M/sec | 5.1M/sec | 2.6x faster | | validate(obj) valid (isolated) | 68M ops/sec | 8M ops/sec | 8.5x faster | | validate(obj) invalid (isolated) | 17M ops/sec | 8M ops/sec | 2.1x faster | | validateJSON(str) valid | 3.0M ops/sec | 1.9M ops/sec | 1.6x faster | | Fastify startup (500 routes) | 46ms | 77ms (standalone) | 1.7x faster | | Schema compilation | 113K ops/sec | 818 ops/sec | 138x faster |

Things only ata can do

  • RE2 regex engine - linear-time guaranteed, immune to ReDoS attacks
  • Multi-core parallel validation - NDJSON batch at 12.5M items/sec
  • Standard Schema V1 - native support, ajv doesn't have it
  • 138x faster compilation - serverless cold starts, dynamic schemas

License

MIT