Skip to content

Commit

Permalink
Merge pull request #13 from aziontech/stage
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
jotanarciso authored Jul 18, 2024
2 parents 439681b + 2c346fc commit 4872e7b
Show file tree
Hide file tree
Showing 67 changed files with 6,913 additions and 2,016 deletions.
27 changes: 0 additions & 27 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run lint && npm run format
npm run lint && npm run format:check
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## [1.2.0-stage.2](https://github.com/aziontech/lib/compare/v1.2.0-stage.1...v1.2.0-stage.2) (2024-07-18)


### Features

* **config:** azionconfig validator ([7f71be4](https://github.com/aziontech/lib/commit/7f71be43532b48fabb36401710293f10240a9570))
* edge-sql and edge-storage ([a8f39c6](https://github.com/aziontech/lib/commit/a8f39c687909f4f58c5a4e2ca5045e2c54a656a1))
* examples ([ff352f2](https://github.com/aziontech/lib/commit/ff352f2a588e4d5da0f60ceb9359faa7bd7be66e))
* improve types/interfaces ([383eb3c](https://github.com/aziontech/lib/commit/383eb3c97d62ab5be12acda76e3c7bf6bac27f14))
* purge package ([9c7038b](https://github.com/aziontech/lib/commit/9c7038b8cd8a96d3fb3c62b0f1f7b319c7984ac3))

## [1.2.0-stage.1](https://github.com/aziontech/lib/compare/v1.1.0...v1.2.0-stage.1) (2024-07-10)


### Features

* **cookies:** Implementing package functionalities (#9) ([131dbe4](https://github.com/aziontech/lib/commit/131dbe4781b10970693da1dc22fbb7a28c366e4a))

## [1.1.0](https://github.com/aziontech/lib/compare/v1.0.0...v1.1.0) (2024-05-03)


Expand Down
321 changes: 313 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,324 @@
# Azion Packages
# Azion Lib

Azion Packages for Edge Computing.
The 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.

## Install
These 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.

```bash
## Table of Contents

npm install
- [Installation](#installation)
- [Products](#products)
- [Client](#client)
- [Storage](#storage)
- [SQL](#sql)
- [Purge](#purge)
- [Utilities](#utilities)
- [Cookies](#cookies)
- [WASM Image Processor](#wasm-image-processor)
- [AzionConfig](#config)
- [Contributing](#contributing)

## Installation

Install the package using npm or yarn:

```sh
npm install azion
```

or

```sh
yarn add azion
```

## Products

### Client

The Azion Client provides a unified interface to interact with all Azion services.

#### Examples

**JavaScript:**

```javascript
import { createClient } from 'azion';

const client = createClient({ token: 'your-api-token', debug: true });

// Storage
const newBucket = await client.storage.createBucket('my-new-bucket', 'public');
console.log(`Bucket created with name: ${newBucket.name}`);

const allBuckets = await client.storage.getBuckets();
console.log(`Retrieved ${allBuckets.length} buckets`);

// SQL
const newDatabase = await client.sql.createDatabase('my-new-db');
console.log(`Database created with ID: ${newDatabase.id}`);

const allDatabases = await client.sql.getDatabases();
console.log(`Retrieved ${allDatabases.length} databases`);

// Purge
const purgeResult = await client.purge.purgeURL(['http://example.com/image.jpg']);
console.log(`Purge successful: ${purgeResult.items}`);
```

**TypeScript:**

```typescript
import { createClient } from 'azion';
import { AzionClient, Bucket, Database, Purge } from 'azion/types';

const client: AzionClient = createClient({ token: 'your-api-token', debug: true });

// Storage
const newBucket: Bucket | null = await client.storage.createBucket('my-new-bucket', 'public');
console.log(`Bucket created with name: ${newBucket.name}`);

const allBuckets: Bucket[] | null = await client.storage.getBuckets();
console.log(`Retrieved ${allBuckets.length} buckets`);

// SQL
const newDatabase: Database | null = await client.sql.createDatabase('my-new-db');
console.log(`Database created with ID: ${newDatabase.id}`);

const allDatabases: Database[] | null = await client.sql.getDatabases();
console.log(`Retrieved ${allDatabases.length} databases`);

// Purge
const purgeResult: Purge | null = await client.purge.purgeURL(['http://example.com/image.jpg']);
console.log(`Purge successful: ${purgeResult.items}`);
```

### Storage

The Storage library provides methods to interact with Azion Edge Storage.

#### Examples

**JavaScript:**

```javascript
import { createClient } from 'azion/storage';

const client = createClient({ token: 'your-api-token', debug: true });

const newBucket = await client.createBucket('my-new-bucket', 'public');
if (newBucket) {
console.log(`Bucket created with name: ${newBucket.name}`);
}

const allBuckets = await client.getBuckets();
if (allBuckets) {
console.log(`Retrieved ${allBuckets.length} buckets`);
}
```

**TypeScript:**

```typescript
import { createClient } from 'azion/storage';
import { StorageClient, Bucket } from 'azion/storage/types';

const client: StorageClient = createClient({ token: 'your-api-token', debug: true });

const newBucket: Bucket | null = await client.createBucket('my-new-bucket', 'public');
if (newBucket) {
console.log(`Bucket created with name: ${newBucket.name}`);
}

const allBuckets: Bucket[] | null = await client.getBuckets();
if (allBuckets) {
console.log(`Retrieved ${allBuckets.length} buckets`);
}
```

Read more in the [Storage README](./packages/storage/README.md).

### SQL

The SQL library provides methods to interact with Azion Edge SQL databases.

#### Examples

**JavaScript:**

```javascript
import { createClient } from 'azion/sql';

const client = createClient({ token: 'your-api-token', debug: true });

const newDatabase = await client.createDatabase('my-new-db');
if (newDatabase) {
console.log(`Database created with ID: ${newDatabase.id}`);
}

const allDatabases = await client.getDatabases();
if (allDatabases) {
console.log(`Retrieved ${allDatabases.length} databases`);
}
```

**TypeScript:**

```typescript
import { createClient } from 'azion/sql';
import { SQLClient, Database } from 'azion/sql/types';

const client: SQLClient = createClient({ token: 'your-api-token', debug: true });

const newDatabase: Database | null = await client.createDatabase('my-new-db');
if (newDatabase) {
console.log(`Database created with ID: ${newDatabase.id}`);
}

const allDatabases: Database[] | null = await client.getDatabases();
if (allDatabases) {
console.log(`Retrieved ${allDatabases.length} databases`);
}
```

Read more in the [SQL README](./packages/sql/README.MD).

### Purge

The Purge library provides methods to purge URLs, Cache Keys, and Wildcard expressions from the Azion Edge cache.

#### Examples

**JavaScript:**

```javascript
import { createClient } from 'azion/purge';

const client = createClient({ token: 'your-api-token', debug: true });

const purgeResult = await client.purgeURL(['http://example.com/image.jpg']);
if (purgeResult) {
console.log(`Purge successful: ${purgeResult.items}`);
}

const cacheKeyResult = await client.purgeCacheKey(['my-cache-key-1', 'my-cache-key-2']);
if (cacheKeyResult) {
console.log(`Cache key purge successful: ${cacheKeyResult.items}`);
}
```

**TypeScript:**

```typescript
import { createClient } from 'azion/purge';
import { PurgeClient, Purge } from 'azion/purge/types';

const client: PurgeClient = createClient({ token: 'your-api-token', debug: true });

const purgeResult: Purge | null = await client.purgeURL(['http://example.com/image.jpg']);
if (purgeResult) {
console.log(`Purge successful: ${purgeResult.items}`);
}

const cacheKeyResult: Purge | null = await client.purgeCacheKey(['my-cache-key-1', 'my-cache-key-2']);
if (cacheKeyResult) {
console.log(`Cache key purge successful: ${cacheKeyResult.items}`);
}
```

Read more in the [Purge README](./packages/purge/README.md).

## Utilities

### Cookies

The Cookies library provides methods to get and set cookies.

#### Examples

**JavaScript:**

```javascript
import { getCookie, setCookie } from 'azion/cookies';

const myCookie = getCookie(request, 'my-cookie');
setCookie(response, 'my-cookie', 'cookie-value', { maxAge: 3600 });
```

## Compile (Build)
**TypeScript:**

```typescript
import { getCookie, setCookie } from 'azion/cookies';
import { CookieOptions } from 'azion/cookies/types';

const myCookie: string | undefined = getCookie(request, 'my-cookie');
const options: CookieOptions = { maxAge: 3600 };
setCookie(response, 'my-cookie', 'cookie-value', options);
```

Read more in the [Cookies README](./packages/cookies/README.md).

### WASM Image Processor

```bash
The WASM Image Processor library provides methods to process images using WebAssembly.

npm run compile
#### Examples

**JavaScript:**

```javascript
import { loadImage } from 'azion/wasm-image-processor';

const image = await loadImage('https://example.com/image.jpg');
image.resize(0.5, 0.5);
const image = image.getImageResponse('jpeg');
console.log(imageResponse);
```

**TypeScript:**

```typescript
import { loadImage } from 'azion/wasm-image-processor';
import { WasmImage } from 'azion/wasm-image-processor/types';

const image: WasmImage = await loadImage('https://example.com/image.jpg');
image.resize(0.5, 0.5);
const imageResponse = image.getImageResponse('jpeg');
console.log(imageResponse);
```

Read more in the [WASM Image Processor README](./packages/wasm-image-processor/README.md).

## Config

The Config library provides methods to configure and validate options for the Azion platform.

### Examples

**JavaScript:**

```javascript
import { AzionConfig } from 'azion';

const config = AzionConfig({
origin: [],
cache: [],
rules: [],
});
```

```typescript
import { AzionConfig } from 'azion';

const config = AzionConfig({
origin: [],
cache: [],
rules: [],
});
```

Read more in the [CONFIG README](./packages/config/README.MD).

## Contributing

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

0 comments on commit 4872e7b

Please sign in to comment.