Skip to content

Commit

Permalink
chore: File formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pigri committed Jan 7, 2025
1 parent 16de3a1 commit c4547e8
Show file tree
Hide file tree
Showing 7 changed files with 544 additions and 496 deletions.
10 changes: 5 additions & 5 deletions .eslint.rc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module' // Allows for the use of imports
sourceType: 'module', // Allows for the use of imports
},
root: true,
env: { node: true, browser: true, serviceworker: true },
Expand Down Expand Up @@ -35,8 +35,8 @@ module.exports = {
{
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
caughtErrors: 'none'
}
caughtErrors: 'none',
},
],
'no-useless-return': 'error',
'prefer-promise-reject-errors': 'error',
Expand All @@ -49,6 +49,6 @@ module.exports = {
'template-curly-spacing': ['error', 'never'],
'func-names': ['error', 'always'],
'padding-line-between-statements': ['error', { blankLine: 'always', prev: '*', next: 'return' }],
'arrow-parens': [2, 'as-needed']
}
'arrow-parens': [2, 'as-needed'],
},
};
63 changes: 31 additions & 32 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: [ "main" ]
branches: ['main']
pull_request:
branches: [ "main" ]
branches: ['main']
schedule:
- cron: '35 10 * * 4'

Expand All @@ -40,45 +40,44 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript-typescript' ]
language: ['javascript-typescript']
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: '/language:${{matrix.language}}'
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,91 @@
# cf-n8n-proxy

Cloudflare worker for n8n proxy

### Why do you need this?

- You can use this service to protect your n8n instance from DDoS attacks.
- You can use this service to hide your n8n instance from the public.
- You can use this service to add rate limiting to your n8n instance.
- You can use this service to add deduplication to your n8n instance.
- You can use this service to add a queue to your n8n instance.
- You can use this service to add a retry mechanism to your n8n instance.


### Requirements:

- You need a paid Worker plan ($5 USD) for this service due to the queue.
- A cloudflare domain

### Architecture:

cloudflare -> cloudflare worker -> n8n

## How to use?

### Wrangler install

```
npm install -g wrangler pnpm
```

### NPM package install

```
pnpm install
```

### Wrangler login

```
wrangler login
```

### Create your wrangler config

```
cp wrangler.toml_example wrangler.toml
```

- Change everywhere `example.com` to your domain


### Create queue

```
wrangler queues create cf-n8n-proxy-production -e production
wrangler queues create dlq-cf-n8n-proxy-production -e production
```

### Enable deduplication feature

```
wrangler kv:namespace create cf-n8n-proxy
```

- Replace `<mykvid>` with the response ID in the wrangler.toml file.
- Change `DEDUPLICATION_ENABLED=false` to `DEDUPLICATION_ENABLED=true` in the wrangler.toml file.

### IMPORTANT NOTES ABOUT DEDUPLICATION "As of January 2022, expiration targets that are less than 60 seconds into the future are not supported. This is true for both expiration methods."

- `DEDUPLICATION_TTL` is optional; by default, it is set to 60 seconds.

### Rate limiting

- Change `RATE_LIMITING_ENABLED=false` to `RATE_LIMITING_ENABLED=true` in the wrangler.toml file.

#### Default 100 requests per minute

```
simple = { limit = 100, period = 60 }
```

### Deploy your service

```
wrangler deploy -e production
```

### How to test in local?

```
wrangler dev
```
Loading

0 comments on commit c4547e8

Please sign in to comment.