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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@verisure-italy/zipcode-types

v1.7.2

Published

Types for ZipCode service

Readme

ZipCode Types

TypeScript types and Zod schemas for ZipCode service entities. This package provides type-safe definitions for areas and enabled zip codes.

Features

  • Type-Safe - Full TypeScript support with Zod runtime validation
  • Shared Types - Built on top of @verisure-italy/shared-types
  • Runtime Validation - Zod schemas for request/response validation
  • Tree-Shakeable - ESM and CJS support for optimal bundle size

Installation

pnpm add @verisure-italy/zipcode-types

Types

Area

Represents a geographic area with zip code information.

import { Area, areaSchema } from '@verisure-italy/zipcode-types'

// TypeScript type
const area: Area = {
  id: '123e4567-e89b-12d3-a456-426614174000',
  city: 'Milano',
  province: 'MI',
  region: 'Lombardia',
  town: 'Milano',
  zipCode: '20100',
}

// Runtime validation with Zod
const result = areaSchema.safeParse(data)
if (result.success) {
  const validArea: Area = result.data
}

Schema:

const areaSchema = z.object({
  id: z.uuid(),                                              // UUID v4
  city: z.string().min(2, 'city.required'),                 // Min 2 chars
  province: z.string().min(2).max(3),                       // 2-3 chars (e.g., MI, RM)
  region: z.string().min(2, 'region.required'),            // Min 2 chars
  town: z.string().min(2, 'town.required'),                // Min 2 chars
  zipCode: zipCodeSchema,                                    // From shared-types
})

Enabled

Represents an enabled zip code.

import { Enabled, enabledSchema } from '@verisure-italy/zipcode-types'

// TypeScript type
const enabled: Enabled = {
  zipCode: '20100',
}

// Runtime validation with Zod
const result = enabledSchema.safeParse(data)
if (result.success) {
  const validEnabled: Enabled = result.data
}

Schema:

const enabledSchema = z.object({
  zipCode: zipCodeSchema,  // From shared-types
})

Usage Examples

Express Route with Validation

import express from 'express'
import { areaSchema, type Area } from '@verisure-italy/zipcode-types'

const router = express.Router()

router.post('/areas', async (req, res) => {
  // Validate request body
  const result = areaSchema.safeParse(req.body)
  
  if (!result.success) {
    return res.status(400).json({ 
      error: 'Invalid area data',
      details: result.error.issues 
    })
  }
  
  const area: Area = result.data
  // ... save to database ...
  
  res.json(area)
})

With Router Middleware

import { createRestResource } from '@verisure-italy/router-middleware'
import { areaSchema, type Area } from '@verisure-italy/zipcode-types'

const areaResource = createRestResource<Area>({
  name: 'area',
  schema: areaSchema,
  // ... repository methods ...
})

// Validation is handled automatically by router-middleware

Type Guards

import { areaSchema, type Area } from '@verisure-italy/zipcode-types'

function isValidArea(data: unknown): data is Area {
  return areaSchema.safeParse(data).success
}

// Usage
if (isValidArea(unknownData)) {
  // TypeScript knows this is an Area
  console.log(unknownData.city)
}

Dependencies

  • @verisure-italy/shared-types - Provides zipCodeSchema and other shared types
  • zod ^4.1.12 - Runtime validation library

Related Packages

TypeScript Configuration

This package is built with TypeScript 5.9+ and exports both type definitions and runtime schemas.

{
  "compilerOptions": {
    "moduleResolution": "bundler",
    "module": "ESNext",
    "target": "ES2022"
  }
}

License

Internal Verisure Italy package