Skip to content

Commit

Permalink
Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
helius-wedtm committed Mar 5, 2023
0 parents commit c909713
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = tab
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
18 changes: 18 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build
on:
push:
pull_request:
repository_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 60
needs: test
steps:
- uses: actions/checkout@v2
- name: Publish
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
env:
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
/node_modules
*-lock.*
*.lock
*.log

/dist
19 changes: 19 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"semi": true,
"printWidth": 100,
"singleQuote": true,
"bracketSpacing": true,
"insertPragma": false,
"requirePragma": false,
"jsxSingleQuote": false,
"bracketSameLine": false,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "css",
"vueIndentScriptAndStyle": true,
"quoteProps": "consistent",
"proseWrap": "preserve",
"trailingComma": "es5",
"arrowParens": "avoid",
"useTabs": true,
"tabWidth": 2
}
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Helius RPC Proxy

> NOTE: You must have an existing Helius account and API key for this to work! Get one for free at https://helius.xyz.
This repo hosts a one-click-deploy Cloudflare worker that proxies RPC requests to Helius.


## Step 1

Press the button below to deploy this to your own Cloudflare account:

[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/helius-labs/helius-rpc-proxy)

## Step 2

Navigate to your newly deployed worker, and click "Settings" and then "Variables":
![Variables](docs/add_variable.png)

## Step 3
Add a new variable with the key name `HELIUS_API_KEY` and your Helius API key as the value:
![Add Secret](docs/add_secret.png)

***NOTE:*** We recommend selecting "Encrypt". This will hide your key from the UI and API responses, and redact them from logs.
![Encrypt](docs/encrypt.png)

## Step 4
Refresh the page and confirm that your key is now saved and encrypted:
![Confirm](docs/confirm.png)

You can now use your worker URL as an the RPC endpoint in all SDK and client side configurations without your API key leaking!
Binary file added docs/add_secret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/add_variable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/confirm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/encrypt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"private": true,
"version": "0.0.0",
"scripts": {
"deploy": "wrangler publish src/index.ts",
"dev": "wrangler dev src/index.ts --local",
"test": "vitest",
"start-stackblitz": "WRANGLER_SEND_METRICS=false wrangler dev src/index.ts --local"
},
"devDependencies": {
"@cloudflare/workers-types": "^3.0.0",
"vitest": "^0.24.5",
"wrangler": "^2.1.14"
}
}
15 changes: 15 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
interface Env {
HELIUS_API_KEY: string;
}

export default {
async fetch(request: Request, env: Env) {
const proxyRequest = new Request(`https://rpc.helius.xyz/?api-key=${env.HELIUS_API_KEY}`, {
method: request.method,
headers: request.headers,
body: request.body,
});

return fetch(proxyRequest);
},
};
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"noEmit": true,
"module": "esnext",
"target": "es2020",
"lib": ["es2020"],
"strict": true,
"alwaysStrict": true,
"preserveConstEnums": true,
"moduleResolution": "node",
"sourceMap": true,
"types": ["@cloudflare/workers-types"]
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
3 changes: 3 additions & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "rpc-proxy" # todo
main = "./src/index.ts"
compatibility_date = "2022-05-03"

0 comments on commit c909713

Please sign in to comment.