Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamlacombe/cloudflare-expression-builder
🦕☁️🔥 Deno module for easy, type-safe building and validation of Cloudflare firewall expressions.
https://github.com/adamlacombe/cloudflare-expression-builder
cloudflare cloudflare-expression cloudflare-waf deno typescript
Last synced: about 2 months ago
JSON representation
🦕☁️🔥 Deno module for easy, type-safe building and validation of Cloudflare firewall expressions.
- Host: GitHub
- URL: https://github.com/adamlacombe/cloudflare-expression-builder
- Owner: adamlacombe
- License: mit
- Created: 2023-07-30T02:50:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-24T23:08:34.000Z (over 1 year ago)
- Last Synced: 2024-05-02T05:56:30.877Z (10 months ago)
- Topics: cloudflare, cloudflare-expression, cloudflare-waf, deno, typescript
- Language: TypeScript
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cloudflare Expression Builder
**NOTE:** Still a work in progress. Not ready for production use.
Cloudflare Expression Builder is a Deno module that simplifies the creation of
expressions for Cloudflare's firewall rules. It provides a fluent API to build
complex expressions and includes a validation method that uses Cloudflare's API
to ensure the expression is valid.## Features
- Fluent API for building expressions
- Supports all Cloudflare firewall fields and operators
- Validates expressions using Cloudflare's API
- Supports both free and paid Cloudflare plans## Usage
Here's an example of how to use the ExpressionBuilder:
```typescript
import { ExpressionBuilder } from "https://deno.land/x/cloudflare_expression_builder/mod.ts";const builder = new ExpressionBuilder();
builder.addExpression("ip.src", "==", "1.2.3.4")
.and()
.addExpression("http.request.uri.path", "contains", "/admin");console.log(builder.build()); // Outputs: ip.src == 1.2.3.4 and http.request.uri.path contains "/admin"
```You can also validate the expression using Cloudflare's API:
```typescript
const isValid = await builder.validate();
console.log(isValid); // Outputs: true or throws an error
```## Contributing
Pull requests are welcome. For major changes, please open an issue first to
discuss what you would like to change.Please make sure to update tests as appropriate.