{"id":32551207,"url":"https://github.com/aziontech/lib","last_synced_at":"2026-03-04T19:03:09.739Z","repository":{"id":252825566,"uuid":"777948940","full_name":"aziontech/lib","owner":"aziontech","description":"Library to interact with Azion products using TypeScript.","archived":false,"fork":false,"pushed_at":"2026-03-03T17:49:08.000Z","size":4199,"stargazers_count":8,"open_issues_count":9,"forks_count":4,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-03-03T21:32:40.682Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.azion.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aziontech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-26T19:55:24.000Z","updated_at":"2026-02-13T17:23:44.000Z","dependencies_parsed_at":"2024-08-12T20:26:40.757Z","dependency_job_id":"62dad9d0-4c34-411b-89f6-4dd3b4c895cc","html_url":"https://github.com/aziontech/lib","commit_stats":null,"previous_names":["aziontech/lib"],"tags_count":239,"template":false,"template_full_name":null,"purl":"pkg:github/aziontech/lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziontech%2Flib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziontech%2Flib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziontech%2Flib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziontech%2Flib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aziontech","download_url":"https://codeload.github.com/aziontech/lib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziontech%2Flib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30090038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T18:31:08.343Z","status":"ssl_error","status_checked_at":"2026-03-04T18:31:07.708Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-28T20:58:59.479Z","updated_at":"2026-03-04T19:03:09.721Z","avatar_url":"https://github.com/aziontech.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/azion-lib.svg\" alt=\"Azion Lib Logo\" width=\"180\"/\u003e\n\u003c/p\u003e\n\n# Azion Library - The Edge Developer's Toolkit\n\n[![Version](https://img.shields.io/npm/v/azion.svg)](https://www.npmjs.com/package/azion)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)\n[![Downloads](https://img.shields.io/npm/dm/azion.svg)](https://www.npmjs.com/package/azion)\n[![GitHub Stars](https://img.shields.io/github/stars/aziontech/lib.svg)](https://github.com/aziontech/lib/stargazers)\n[![Maintainers](https://img.shields.io/badge/maintainers-jotanarciso,%20jcbsfilho,%20pablodiehl-blue.svg)](https://github.com/aziontech/lib/graphs/contributors)\n\nThe Azion Libraries provide a suite of tools to interact with various Azion services, including Products (Purge, SQL, Storage) and Utilities (WASM Image Processor, Cookies). Each library is configurable and supports debug mode and environment variable-based configuration.\n\nThese libraries are designed to be versatile and can be used both within and outside of the Azion Runtime environment. When used outside of the Azion Runtime, the libraries will interact with Azion services via REST APIs. However, when used within the `Azion Runtime`, the libraries will leverage internal runtime capabilities for enhanced performance and efficiency.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Client](#client)\n  - [Storage](./packages/storage/README.md)\n  - [SQL](./packages/sql/README.md)\n  - [Purge](./packages/purge/README.md)\n  - [Domains](./packages/domains/README.md)\n  - [Applications](./packages/applications/README.md)\n- Utilities\n  - [Cookies](./packages/cookies/README.md)\n  - [Jwt](./packages/jwt/README.md)\n  - [WASM Image Processor](./packages/wasm-image-processor/README.md)\n  - [Utils](./packages/utils/README.md)\n- [AI](./packages/ai/README.md)\n- [Types](#types)\n- [AzionConfig](#config)\n- [Contributing](#contributing)\n\n## Installation\n\nInstall the package using npm or yarn:\n\n```sh\nnpm install azion\n```\n\nor\n\n```sh\nyarn add azion\n```\n\n## Usage\n\n### Using the Client vs. Independent Package Functions\n\nThe Azion client provides a unified interface to interact with all products and services. You can use the client to access and manage all functionalities across Storage, SQL, Purge, and more. When using the client, you can pass configurations (e.g., `token`, `debug`) explicitly as parameters.\n\n```javascript\nimport { createClient } from 'azion';\n\nconst client = createClient({ token: 'your-api-token', debug: true });\n\n// Example: Creating a database via the client\nconst { data: newDatabase, error } = await client.sql.createDatabase('my-new-database');\nif (data) {\n  console.log(`Database created with ID: ${newDatabase.id}`);\n} else {\n  console.error('Failed to create database', error);\n}\n```\n\nAlternatively, if you prefer to use individual functions directly from each package, you need to configure tokens and settings via environment variables (e.g., using a `.env` file). Each module has its own internal client that manages the interaction.\n\nExample with explicit client for a specific module:\n\n```typescript\nimport { createClient, StorageClient } from 'azion/storage';\n\nconst client: StorageClient = createClient({ token: 'your-api-token', debug: true });\n\nconst { data, error }: AzionStorageResponse\u003cAzionBucket\u003e = await client.createBucket({\n  name: 'my-new-bucket',\n  workloads_access: 'read_only',\n});\n\nif (data) {\n  console.log(`Bucket created with name: ${data.name}`);\n} else {\n  console.error('Failed to create bucket', error);\n}\n```\n\nYou can also use individual functions without any client by importing them directly from the package. This approach requires environment variables for configuration:\n\n```javascript\nimport { createDatabase } from 'azion/sql';\n\nconst { data, error } = await createDatabase('my-new-database', { debug: true });\nif (data) {\n  console.log(`Database created with ID: ${data.id}`);\n} else {\n  console.error('Failed to create database', error);\n}\n```\n\nMore information on specific functionalities and usage can be found in the README file of each package (e.g., [Storage README](./packages/storage/README.md), [SQL README](./packages/sql/README.md), etc.).\n\nThis flexibility allows you to either manage everything through the client for simplicity or call specific functions from each package with more control over environment configurations.\n\n### Client\n\nThe Azion Client provides a unified interface to interact with all Azion services.\n\n#### Examples\n\n**JavaScript:**\n\n```javascript\nimport { createClient } from 'azion';\n\nconst client = createClient({ token: 'your-api-token', debug: true });\n\n// Storage\nconst { data: newBucket, error } = await client.storage.createBucket({ name: 'my-new-bucket', workloads_access: 'read_only' });\nconsole.log(`Bucket created with name: ${newBucket.name}`);\n\nconst { data: allBuckets, error } = await client.storage.getBuckets();\nconsole.log(`Retrieved ${allBuckets.count} buckets`);\n\n// SQL\nconst { data: newDatabase, error } = await client.sql.createDatabase('my-new-db');\nconsole.log(`Database created with ID: ${newDatabase.id}`);\n\nconst { data: allDatabases, error } = await client.sql.getDatabases();\nconsole.log(`Retrieved ${allDatabases.count} databases`);\n\n// Purge\nconst { data: purgeResult, error } = await client.purge.purgeURL(['http://example.com/image.jpg']);\nconsole.log(`Purge successful: ${purgeResult.items}`);\n```\n\n**TypeScript:**\n\n```typescript\nimport { createClient } from 'azion';\nimport type { AzionClient } from 'azion/client';\nimport type { AzionDatabaseResponse, AzionDatabaseQueryResponse, AzionDatabaseCollection } from 'azion/sql';\nimport type { AzionStorageResponse, AzionBucket, AzionBucketCollection } from 'azion/storage';\nimport type { AzionPurgeResponse, AzionPurge } from 'azion/purge';\n\nconst client: AzionClient = createClient({ token: 'your-api-token', debug: true });\n\n// Storage\nconst { data: newBucket, error }: AzionStorageResponse\u003cAzionBucket\u003e = await client.createBucket({\n  name: 'my-new-bucket',\n  workloads_access: 'read_only',\n});\nconsole.log(`Bucket created with name: ${newBucket.name}`);\n\nconst { data: allBuckets, error }: AzionStorageResponse\u003cAzionBucketCollection\u003e = await client.getBuckets();\nconsole.log(`Retrieved ${allBuckets.count} buckets`);\n\n// SQL\nconst { data: newDatabase, error }: AzionDatabaseResponse\u003cAzionDatabase\u003e = await client.sql.createDatabase('my-new-db');\nconsole.log(`Database created with ID: ${newDatabase.id}`);\n\nconst { data: allDatabases, error }: AzionDatabaseResponse\u003cAzionDatabaseCollections\u003e = await client.sql.getDatabases();\nconsole.log(`Retrieved ${allDatabases.count} databases`);\n\n// Purge\nconst { data: purgeResult, error }: AzionPurgeResponse\u003cAzionPurge\u003e = await client.purge.purgeURL([\n  'http://example.com/image.jpg',\n]);\nconsole.log(`Purge successful: ${purgeResult.items}`);\n```\n\n## Types\n\nThe Types package provides global TypeScript types that are used across Azion platform, ensuring consistency and reducing redundancy throughout the codebase.\n\n⚠️ These types are specifically tailored for `Azion Runtime environments`.\n\n#### Available Types\n\n- **`Metadata`**  \n  Represents metadata information for requests, including GeoIP data, remote address, server protocol, and TLS information.\n\n- **`FetchEvent`**  \n  Represents the FetchEvent interface, which includes the request object and methods to handle fetch events within the Azion Runtime.\n\n- **`FirewallEvent`**  \n  Represents the FirewallEvent interface, including methods to manage firewall events such as denying, dropping, or continuing a request.\n\nRead more in the [Types README](./packages/types/README.md).\n\n## Config\n\nThe Config library provides methods to configure and validate options for the Azion platform.\n\n### Examples\n\n**JavaScript:**\n\nThis is the first example using JSDoc to provide type information:\n\n```javascript\n/** @type {import('azion').AzionConfig} */\nconst config = {\n  build: {\n    // Build configuration\n    bundler: 'esbuild',\n    entry: './src/index.js',\n    preset: 'react',\n    polyfills: true,\n  },\n  workloads: [\n    {\n      name: 'my-production-workload',\n      active: true,\n      infrastructure: 1,\n      domains: ['example.com'],\n      workloadDomainAllowAccess: false,\n      protocols: {\n        http: {\n          versions: ['http1', 'http2'],\n          httpPorts: [80],\n          httpsPorts: [443],\n        },\n      },\n    },\n  ],\n  connectors: [\n    {\n      name: 'My Origin',\n      type: 'http',\n      active: true,\n      attributes: {\n        addresses: [\n          {\n            address: 'origin.example.com',\n            weight: 100,\n          },\n        ],\n        connectionOptions: {\n          protocolPolicy: 'https',\n        },\n      },\n    },\n  ],\n  applications: [\n    {\n      name: 'My App',\n      active: true,\n      cache: [\n        {\n          name: 'Default Cache',\n          browser: { maxAgeSeconds: 3600 },\n          edge: { maxAgeSeconds: 7200 },\n        },\n      ],\n      rules: [\n        {\n          name: 'Example Rule',\n          phase: 'request',\n          criteria: [\n            {\n              variable: 'request_uri',\n              operator: 'matches',\n              conditional: 'if',\n              input_value: '/api/*',\n            },\n          ],\n          behaviors: [\n            {\n              type: 'set_origin',\n              attributes: {\n                name: 'My Origin',\n              },\n            },\n          ],\n        },\n      ],\n    },\n  ],\n  purge: [\n    {\n      type: 'url',\n      urls: ['https://example.com/path/to/purge'],\n    },\n  ],\n  networkList: [\n    {\n      id: 12345,\n      listType: 'ip_cidr',\n      listContent: ['10.0.0.1'],\n    },\n  ],\n  firewall: {\n    name: 'My Firewall',\n    active: true,\n    rules: [\n      {\n        name: 'Block Suspicious IPs',\n        behaviors: [\n          {\n            type: 'deny',\n          },\n        ],\n      },\n    ],\n  },\n  waf: [\n    {\n      name: 'My WAF',\n      active: true,\n      engineSettings: {\n        useGeolocation: true,\n        useReputation: true,\n        thresholds: {\n          sql_injection: 'high',\n          cross_site_scripting: 'medium',\n        },\n      },\n    },\n  ],\n  // Other configurations...\n};\n\nexport default config;\n```\n\nThis is the second example using the `defineConfig` function to enforce types and provide configuration:\n\n```javascript\nimport { defineConfig } from 'azion';\n\nconst config = defineConfig({\n  build: {\n    // Advanced build configuration options\n    bundler: 'esbuild',\n    entry: './src/index.js',\n    preset: {\n      config: {\n        /* custom configuration */\n      },\n      metadata: {\n        name: 'custom-preset',\n        registry: 'my-registry',\n      },\n      handler: async (event) =\u003e {\n        // Custom handler\n        return new Response('Hello World');\n      },\n    },\n    polyfills: true,\n    extend: (config) =\u003e {\n      // Customize bundler configuration\n      return {\n        ...config,\n        // Specific configurations\n      };\n    },\n    memoryFS: {\n      injectionDirs: ['./src/inject'],\n      removePathPrefix: './src',\n    },\n  },\n  // Other configurations...\n});\n\nexport default config;\n```\n\nHere's a more advanced example using preset customization with TypeScript:\n\n```typescript\nimport { defineConfig } from 'azion';\nimport type { AzionBuildPreset, AzionPrebuildResult, BuildContext, BuildConfiguration } from 'azion/config';\nimport { Next } from 'azion/presets';\n\nexport default defineConfig({\n  build: {\n    preset: {\n      ...Next,\n      config: {\n        ...Next.config,\n        bundler: 'esbuild',\n        extend: (config) =\u003e {\n          config.define = {\n            ...config.define,\n            'global.customFeature': 'JSON.stringify(true)',\n            'process.env.CUSTOM_VAR': 'JSON.stringify(\"value\")',\n          };\n          return config;\n        },\n      },\n      prebuild: async (config: BuildConfiguration, ctx: BuildContext): Promise\u003cAzionPrebuildResult\u003e =\u003e {\n        // Your custom prebuild logic here\n        console.log('Running custom prebuild with context:', ctx);\n\n        // Return prebuild result with custom configurations\n        return {\n          filesToInject: ['./src/custom-file.js'],\n          injection: {\n            globals: {\n              _ENTRIES: 'window._ENTRIES = {}',\n              AsyncLocalStorage: 'globalThis.AsyncLocalStorage = class {}',\n            },\n            entry: '// Custom entry code\\nconsole.log(\"Custom initialization\");',\n            banner: '/* Custom banner comment */',\n          },\n          bundler: {\n            defineVars: {\n              __CONFIG__: JSON.stringify({ customSetting: true }),\n              __BUILD_METADATA__: JSON.stringify({ version: '1.0.0', buildTime: Date.now() }),\n            },\n            plugins: [],\n          },\n        };\n      },\n      postbuild: async (config: BuildConfiguration, ctx: BuildContext): Promise\u003cvoid\u003e =\u003e {\n        // Your custom postbuild logic here\n        console.log('Build completed with output:', config.baseOutputDir);\n      },\n    },\n    // Other build configurations\n    entry: './src/index.ts',\n    polyfills: true,\n    memoryFS: {\n      injectionDirs: ['./src/inject'],\n      removePathPrefix: './src',\n    },\n  },\n  // Workloads,  connectors, and other configurations...\n});\n```\n\nRead more in the [AzionConfig README](https://github.com/aziontech/lib/tree/main/packages/config/README.md).\n\n## Presets\n\nThe Presets package provides pre-configured presets for different frameworks and libraries to simplify the development process.\n\nRead more in the [Presets README](https://github.com/aziontech/lib/tree/main/packages/presets/README.md).\n\n## Contributing\n\nFeel free to submit issues or pull requests to improve the functionality or documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faziontech%2Flib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faziontech%2Flib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faziontech%2Flib/lists"}