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

@aziontech/utils

v1.0.0

Published

The Azion Utils package provides a set of utility functions designed to simplify common tasks when working with Azion functions.

Readme

Azion Utils

The Azion Utils package provides a set of utility functions designed to simplify common tasks when working with Azion functions. These utilities cover tasks such as routing for Single Page Applications (SPA) and Multi-Page Applications (MPA), as well as parsing and debugging incoming requests.

Table of Contents

Installation

Install the package using npm or yarn:

npm install azion

or

yarn add azion

Usage

mountSPA

The mountSPA function is designed to process requests to a Single Page Application (SPA) that's being computed at the edge of a Content Delivery Network (CDN). It determines whether the incoming request is for a static asset or an application route and then mounts the appropriate request URL for fetching the required resource.

JavaScript Example:

import { mountSPA } from '@aziontech/utils/edge';

const myApp = await mountSPA('https://example.com/');
console.log(myApp);
// Fetches: file:///index.html
// Response object representing the content of index.html

TypeScript Example:

import { mountSPA } from '@aziontech/utils/edge';

const myApp: Response = await mountSPA('https://example.com/');
console.log(myApp);
// Fetches: file:///index.html
// Response object representing the content of index.html

mountMPA

The mountMPA function handles requests for Multi-Page Applications (MPA) at the edge. It processes the incoming request URL, constructs the appropriate asset path, and fetches the corresponding response from the origin server or edge cache.

JavaScript Example:

import { mountMPA } from '@aziontech/utils/edge';

const myApp = await mountMPA('https://example.com/about');
console.log(myApp);
// Fetches: file:///about/index.html
// Response object representing the content of about/index.html

TypeScript Example:

import { mountMPA } from '@aziontech/utils/edge';

const myApp: Response = await mountMPA('https://example.com/about');
console.log(myApp);
// Fetches: file:///about/index.html
// Response object representing the content of about/index.html

parseRequest

The parseRequest function is designed to parse and log the details of an incoming request. It extracts key information such as headers, cookies, body, and client data from the incoming FetchEvent, providing a structured object with all these details for further processing or logging.

JavaScript Example:

import { parseRequest } from '@aziontech/utils';

const parsedRequest = await parseRequest(event);
console.log(parsedRequest);
// Example ParsedRequest object:
// {
//   timestamp: '2024-08-14T12:34:56.789Z',
//   metadata: {
//     geoip_asn: '12345',
//     geoip_city: 'Sao Paulo',
//     geoip_city_continent_code: 'SA',
//     geoip_city_country_code: 'BR',
//     geoip_city_country_name: 'Brazil',
//     geoip_continent_code: 'SA',
//     geoip_country_code: 'BR',
//     geoip_country_name: 'Brazil',
//     geoip_region: 'SP',
//     geoip_region_name: 'Sao Paulo',
//     remote_addr: '192.0.2.1',
//     remote_port: '443',
//     remote_user: 'user',
//     server_protocol: 'HTTP/1.1',
//     ssl_cipher: 'ECDHE-RSA-AES128-GCM-SHA256',
//     ssl_protocol: 'TLSv1.2',
//   },
//   method: 'GET',
//   url: {
//     full: 'https://example.com/',
//     protocol: 'https:',
//     hostname: 'example.com',
//     path: '/',
//     query: {},
//   },
//   headers: {
//     'user-agent': 'Mozilla/5.0 ...',
//     'accept-language': 'en-US,en;q=0.9',
//   },
//   cookies: {
//     'session_id': 'abc123',
//   },
//   body: null,
//   client: {
//     ip: '192.0.2.1',
//     userAgent: 'Mozilla/5.0 ...',
//   },
//   referer: 'Unknown',
//   origin: 'Unknown',
//   cacheControl: 'no-cache',
//   pragma: 'no-cache',
//   contentType: 'text/html',
//   contentLength: '1234',
//   acceptLanguage: 'en-US,en;q=0.9',
//   acceptEncoding: 'gzip, deflate, br',
//   priority: 'High',
//   host: 'example.com',
//   authorization: 'Not Present',
// }

TypeScript Example:

import { parseRequest } from '@aziontech/utils';
import type { ParsedRequest } from '@aziontech/utils';

const parsedRequest: ParsedRequest = await parseRequest(event);
console.log(parsedRequest);
// Example ParsedRequest object:
// {
//   timestamp: '2024-08-14T12:34:56.789Z',
//   metadata: {
//     geoip_asn: '12345',
//     geoip_city: 'Sao Paulo',
//     geoip_city_continent_code: 'SA',
//     geoip_city_country_code: 'BR',
//     geoip_city_country_name: 'Brazil',
//     geoip_continent_code: 'SA',
//     geoip_country_code: 'BR',
//     geoip_country_name: 'Brazil',
//     geoip_region: 'SP',
//     geoip_region_name: 'Sao Paulo',
//     remote_addr: '192.0.2.1',
//     remote_port: '443',
//     remote_user: 'user',
//     server_protocol: 'HTTP/1.1',
//     ssl_cipher: 'ECDHE-RSA-AES128-GCM-SHA256',
//     ssl_protocol: 'TLSv1.2',
//   },
//   method: 'GET',
//   url: {
//     full: 'https://example.com/',
//     protocol: 'https:',
//     hostname: 'example.com',
//     path: '/',
//     query: {},
//   },
//   headers: {
//     'user-agent': 'Mozilla/5.0 ...',
//     'accept-language': 'en-US,en;q=0.9',
//   },
//   cookies: {
//     'session_id': 'abc123',
//   },
//   body: null,
//   client: {
//     ip: '192.0.2.1',
//     userAgent: 'Mozilla/5.0 ...',
//   },
//   referer: 'Unknown',
//   origin: 'Unknown',
//   cacheControl: 'no-cache',
//   pragma: 'no-cache',
//   contentType: 'text/html',
//   contentLength: '1234',
//   acceptLanguage: 'en-US,en;q=0.9',
//   acceptEncoding: 'gzip, deflate, br',
//   priority: 'High',
//   host: 'example.com',
//   authorization: 'Not Present',
// }

API Reference

mountSPA

Processes requests for Single Page Applications, determining the correct path and fetching the required resource.

mountMPA

Handles routing for Multi-Page Applications, constructing the asset path and fetching the corresponding response.

parseRequest

Parses and logs the details of an incoming request, including headers, cookies, and client information.

Contributing

Feel free to submit issues or pull requests to improve the functionality or documentation.