-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 334a86c
Showing
23 changed files
with
4,883 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- **I'm submitting a ...** | ||
[ ] bug report | ||
[ ] feature request | ||
[ ] question about the decisions made in the repository | ||
[ ] question about how to use this project | ||
|
||
- **Summary** | ||
|
||
- **Other information** (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## Why? | ||
|
||
Clear and short explanation here. | ||
|
||
## How? | ||
|
||
- Done A (replace with a breakdown of the steps) | ||
- Done B | ||
- Done C | ||
|
||
## Tickets? | ||
|
||
- [Ticket 1](the-ticket-url-here) | ||
- [Ticket 2](the-ticket-url-here) | ||
- [Ticket 3](the-ticket-url-here) | ||
|
||
## Contribution checklist? | ||
|
||
- [ ] The commit messages are detailed | ||
- [ ] The `build` command runs locally | ||
- [ ] Assets or static content are linked and stored in the project | ||
- [ ] Document filename is named after the slug | ||
- [ ] You've reviewed spelling using a grammar checker | ||
- [ ] For documentation, guides or references, you've tested the commands and steps | ||
- [ ] You've done enough research before writing | ||
|
||
## Security checklist? | ||
|
||
- [ ] Sensitive data has been identified and is being protected properly | ||
- [ ] Injection has been prevented (parameterized queries, no eval or system calls) | ||
- [ ] The Components are escaping output (to prevent XSS) | ||
|
||
## References? | ||
|
||
Optionally, provide references such as links | ||
|
||
## Preview? | ||
|
||
Optionally, provide the preview url here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install dependencies | ||
run: pnpm i --frozen-lockfile | ||
|
||
- name: Run linter | ||
run: pnpm lint | ||
|
||
- name: Run formatter | ||
run: pnpm format:check | ||
|
||
- name: Run tests | ||
run: pnpm test | ||
|
||
- name: Build package | ||
run: pnpm build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Publish to npm | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
cache: 'npm' | ||
|
||
- name: Install dependencies | ||
run: pnpm i --frozen-lockfile | ||
|
||
- name: Build package | ||
run: pnpm build | ||
|
||
- name: Publish to npm | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: npm publish --access public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dist | ||
node_modules | ||
test | ||
src/**.js | ||
coverage | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npx --no-install commitlint --edit "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pnpm test | ||
pnpm lint | ||
pnpm format:check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
src/ | ||
tsconfig.json | ||
jest.config.js | ||
eslint.config.js | ||
commintlint.config.js | ||
.prettierrc | ||
.prettierignore | ||
.husky/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# ⚡️Fleek Proxy | ||
|
||
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-blue.svg)](https://conventionalcommits.org) | ||
|
||
`fleek-proxy` is a lightweight JavaScript package designed to route incoming requests and act as an API Gateway for your app. Built for edge function services, it helps forward and proxy requests to the appropriate destinations. | ||
|
||
# Features | ||
|
||
- **Flexible Routing**: Configure custom routes with wildcards. | ||
- **Proxy Requests**: Forward HTTP requests to specified destinations. | ||
- **Default Route**: Set up a default route to catch unmatched paths. | ||
- **Seamless Integration**: Written in TypeScript for type safety. | ||
|
||
# Installation | ||
|
||
``` | ||
npm install @fleekxyz/proxy | ||
``` | ||
|
||
# Usage | ||
|
||
Here's a basic example of a Fleek edge function, demonstrating how to configure and use the proxy package. | ||
|
||
```typescript | ||
import { createProxy, FleekRequest, FleekResponse } from '@fleekxyz/proxy'; | ||
|
||
// Define your routing rules | ||
const proxy = createProxy({ | ||
routes: { | ||
routes: { | ||
'/api/': 'https://api.foo.com/', | ||
'/external/': 'https://external-service.com/', | ||
}, | ||
default: 'https://fallback-service.com/', | ||
}, | ||
}); | ||
|
||
// Proxy the request and handle the response | ||
|
||
export async function main(req: FleekRequest): Promise<FleekResponse> { | ||
return await proxy.proxyRequest(req); | ||
} | ||
``` | ||
|
||
# Contributing | ||
|
||
Thanks for considering contributing to our project! | ||
|
||
## How to Contribute | ||
|
||
1. Fork the repository. | ||
2. Create a new branch: `git checkout -b feature-branch-name`. | ||
3. Make your changes. | ||
4. Commit your changes using conventional commits. | ||
5. Push to your fork and submit a pull request. | ||
|
||
## Commit Guidelines | ||
|
||
We use [Conventional Commits](https://www.conventionalcommits.org/) for our commit messages: | ||
|
||
- `test`: 💍 Adding missing tests | ||
- `feat`: 🎸 A new feature | ||
- `fix`: 🐛 A bug fix | ||
- `chore`: 🤖 Build process or auxiliary tool changes | ||
- `docs`: ✏️ Documentation only changes | ||
- `refactor`: 💡 A code change that neither fixes a bug or adds a feature | ||
- `style`: 💄 Markup, white-space, formatting, missing semi-colons... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = { extends: ['@commitlint/config-conventional'] }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// @ts-check | ||
|
||
import eslint from '@eslint/js'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
collectCoverage: true, | ||
coverageDirectory: 'coverage', | ||
coverageProvider: 'v8', | ||
testMatch: ['**/*.spec.ts'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "@fleekxyz/proxy", | ||
"version": "0.0.1", | ||
"description": "Proxy for your Fleek edge functions", | ||
"main": "dist/main/index.js", | ||
"types": "dist/main/index.d.ts", | ||
"module": "dist/module/index.js", | ||
"repository": "https://github.com/fleekxyz/fleek-proxy", | ||
"homepage": "https://github.com/fleekxyz/fleek-proxy#readme", | ||
"license": "MIT", | ||
"keywords": ["proxy", "router", "gateway", "api", "fleek", "edge", "serverless"], | ||
"scripts": { | ||
"build": "tsc", | ||
"lint": "eslint 'src/**/*.{js,ts}'", | ||
"format": "prettier . --write", | ||
"format:check": "prettier . --check", | ||
"test": "jest", | ||
"prepare": "husky" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^19.3.0", | ||
"@commitlint/config-conventional": "^19.2.2", | ||
"@eslint/js": "^9.2.0", | ||
"@types/jest": "^29.5.12", | ||
"eslint": "^9.2.0", | ||
"husky": "^9.0.11", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.2.5", | ||
"ts-jest": "^29.1.2", | ||
"typescript": "^5.4.5", | ||
"typescript-eslint": "^7.8.0" | ||
} | ||
} |
Oops, something went wrong.