Skip to content

Commit

Permalink
chore: 🤖 Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmpinto committed May 8, 2024
0 parents commit 334a86c
Show file tree
Hide file tree
Showing 23 changed files with 4,883 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE.md
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.)
39 changes: 39 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
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
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist
node_modules
test
src/**.js
coverage
*.log
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pnpm test
pnpm lint
pnpm format:check
8 changes: 8 additions & 0 deletions .npmignore
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/
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"singleQuote": true,
"printWidth": 120,
"trailingComma": "all"
}
67 changes: 67 additions & 0 deletions README.md
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...
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
6 changes: 6 additions & 0 deletions eslint.config.mjs
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);
7 changes: 7 additions & 0 deletions jest.config.js
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'],
};
33 changes: 33 additions & 0 deletions package.json
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"
}
}
Loading

0 comments on commit 334a86c

Please sign in to comment.