Skip to content

Commit

Permalink
feat: Add retries option and DLQ support
Browse files Browse the repository at this point in the history
  • Loading branch information
pigri committed Mar 14, 2024
1 parent 6bdddbc commit 7a75bf0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ cp wrangler.toml_example wrangler.toml
### Create queue
```
wrangler queues create cf-n8n-proxy-production -e production
wrangler queues create dlq-cf-n8n-proxy-production -e production
```

### Deploy your service
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { preflight, corsify } = createCors({
});
const router = Router();

async function proxy (request: Request, env: Env) {
export async function proxy (request: Request, env: Env) {
let url = new URL(request.url);
const proxyUrl = `${env.PROXY_DOMAIN}${url.pathname}`;
switch (request.method) {
Expand Down Expand Up @@ -48,7 +48,7 @@ async function proxy (request: Request, env: Env) {
}
}

async function createNewRequest(request: Request): Promise<Request> {
export async function createNewRequest(request: Request): Promise<Request> {
const { url, method, headers } = request;
if (method === 'GET' || method === 'HEAD') {
return new Request(url, { method, headers });
Expand Down
2 changes: 2 additions & 0 deletions wrangler.toml_example
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ binding = "ERROR_QUEUE"
queue = "cf-n8n-proxy-production"
max_batch_size = 100
max_batch_timeout = 30
max_retries = 100
dead_letter_queue = "dlq-cf-n8n-proxy-production"

[env.production]
workers_dev = false
Expand Down

0 comments on commit 7a75bf0

Please sign in to comment.