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

xian-ph-address

v1.0.2

Published

This guide explains how to use the **[xian-ph-address](https://www.npmjs.com/package/xian-ph-address)** package in an XianFires project with controllers, routes, and Handlebars templates to build cascading dropdowns (`Region → Province → City → Barangay`)

Readme

📍 xian-ph-address Integration Guide

This guide explains how to use the xian-ph-address package in an XianFires project with controllers, routes, and Handlebars templates to build cascading dropdowns (Region → Province → City → Barangay) for PH address.


🚀 Installation

npm install xian-ph-address

📂 Project Structure

Example structure:

project/
├── controllers/
│   └── addresscontroller.js
├── routes/
│   └── routes.js
├── views/
│   └── index.xian   # your template file
├── index.js           # Xianfires Entry point

⚙️ Controller (controllers/addresscontroller.js)

import { getRegions, getProvinces, getCities, getBarangays } from "xian-ph-address";

const addresscontroller = {
  index: async (req, res) => {
    res.send("Index Page");
  },
  regions: async (req, res) => {
    res.render("index", { regions: getRegions() });
  }
};

export { addresscontroller };

🛣️ Routes (routes/routes.js)

import express from "express";
import { getRegions, getProvinces, getCities, getBarangays } from "xian-ph-address";
import { addresscontroller } from "../controllers/addresscontroller.js";

const router = express.Router();

// Render main page with regions
router.get("/", addresscontroller.regions);

// API endpoints for dependent dropdowns
router.get("/provinces/:regionCode", (req, res) => {
  res.json(getProvinces(req.params.regionCode));
});

router.get("/cities/:provinceCode", (req, res) => {
  res.json(getCities(req.params.provinceCode));
});

router.get("/barangays/:cityCode", (req, res) => {
  res.json(getBarangays(req.params.cityCode));
});

export default router;

🎨 View Template (views/index.xian)

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>PH Address Selector</title>
  </head>
  <body>
    <h2>Select Address</h2>

    <label>Region</label>
    <select id="region">
      <option value="">-- Select Region --</option>
      {{#each regions}}
        <option value="{{ region_code }}">{{ region_name }}</option>
      {{/each}}
    </select>

    <label>Province</label>
    <select id="province"><option value="">-- Select Province --</option></select>

    <label>City</label>
    <select id="city"><option value="">-- Select City --</option></select>

    <label>Barangay</label>
    <select id="barangay"><option value="">-- Select Barangay --</option></select>

    <script>
      const regionEl = document.getElementById("region");
      const provinceEl = document.getElementById("province");
      const cityEl = document.getElementById("city");
      const barangayEl = document.getElementById("barangay");

      regionEl.addEventListener("change", async () => {
        provinceEl.innerHTML = "<option>-- Select Province --</option>";
        cityEl.innerHTML = "<option>-- Select City --</option>";
        barangayEl.innerHTML = "<option>-- Select Barangay --</option>";

        if (!regionEl.value) return;
        const res = await fetch(`/provinces/${regionEl.value}`);
        const provinces = await res.json();
        provinces.forEach(p => provinceEl.add(new Option(p.province_name, p.province_code)));
      });

      provinceEl.addEventListener("change", async () => {
        cityEl.innerHTML = "<option>-- Select City --</option>";
        barangayEl.innerHTML = "<option>-- Select Barangay --</option>";

        if (!provinceEl.value) return;
        const res = await fetch(`/cities/${provinceEl.value}`);
        const cities = await res.json();
        cities.forEach(c => cityEl.add(new Option(c.city_name, c.city_code)));
      });

      cityEl.addEventListener("change", async () => {
        barangayEl.innerHTML = "<option>-- Select Barangay --</option>";

        if (!cityEl.value) return;
        const res = await fetch(`/barangays/${cityEl.value}`);
        const barangays = await res.json();
        barangays.forEach(b => barangayEl.add(new Option(b.brgy_name, b.brgy_code)));
      });
    </script>
  </body>
</html>

🖥️ Usage

  1. Start your server:

    npm run dev

    or

    node app.js
  2. Visit: 👉 http://localhost:3000

  3. Select Region → Province → City → Barangay from the cascading dropdowns.