-
Notifications
You must be signed in to change notification settings - Fork 32
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 4b1e303
Showing
32 changed files
with
7,411 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,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
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,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
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,15 @@ | ||
**/node_modules/ | ||
**/.git | ||
**/README.md | ||
**/LICENSE | ||
**/.vscode | ||
**/npm-debug.log | ||
**/coverage | ||
**/.env | ||
**/.editorconfig | ||
**/.aws | ||
**/.github | ||
**/build | ||
**/.husky | ||
**/dist | ||
**/Dockerfile* |
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,17 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**What is the bug?** | ||
A concise, high level description of the bug and how it affects you | ||
|
||
**How can it be reproduced? (optional)** | ||
Include steps, code samples, replits, screenshots and anything else that would be helpful to reproduce the problem. | ||
|
||
**Additional context (optional)** | ||
Add any other context about the problem 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,19 @@ | ||
--- | ||
name: Feature | ||
about: "Opening new feature requests " | ||
title: "feat: " | ||
labels: "" | ||
assignees: "" | ||
--- | ||
|
||
**What is the feature you would like to implement?** | ||
A concise, high level summary of the feature | ||
|
||
**Why is this feature important?** | ||
An argument for why this feature should be build and how it should be prioritized | ||
|
||
**How should this feature be built? (optional)** | ||
A design for the implementation of the feature | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request 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,21 @@ | ||
## Motivation | ||
|
||
Describe why this issue should be fixed and link to any relevant design docs, issues or other relevant items. | ||
|
||
## Change Summary | ||
|
||
Describe the changes being made in 1-2 concise sentences. | ||
|
||
## Merge Checklist | ||
|
||
_Choose all relevant options below by adding an `x` now or at any time before submitting for review_ | ||
|
||
- [ ] PR title adheres to the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standard | ||
- [ ] PR has a changeset | ||
- [ ] PR has been tagged with a change label(s) (i.e. documentation, feature, bugfix, or chore) | ||
- [ ] PR includes documentation if necessary | ||
- [ ] All commits have been signed | ||
|
||
## Additional Context | ||
|
||
If this is a relatively large or complex change, provide more details here that will help reviewers |
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,79 @@ | ||
name: CI | ||
on: | ||
# CI is run on main because new branches can only access caches from master, not previous branches. | ||
# So building on master allows new PR's to get the cache from before. | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
# prevent multiple simultaneous test runs | ||
concurrency: | ||
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
analyze: | ||
timeout-minutes: 10 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Restore cached dependencies for Node modules. | ||
id: module-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ github.workspace }}/node_modules | ||
key: ${{ runner.os }}--node--${{ hashFiles('**/yarn.lock') }} | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Run build | ||
run: yarn build | ||
|
||
- name: Run linter | ||
run: yarn lint:ci | ||
|
||
test: | ||
timeout-minutes: 10 | ||
runs-on: "buildjet-4vcpu-ubuntu-2204" | ||
|
||
strategy: | ||
matrix: | ||
node_version: [18, 20] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node_version }} | ||
|
||
- name: Restore cached dependencies for Node modules. | ||
id: module-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ github.workspace }}/node_modules | ||
key: ${{ runner.os }}--node--${{ matrix.node_version}}--${{ hashFiles('**/yarn.lock') }} | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Run build | ||
run: yarn build | ||
|
||
- name: Start background services | ||
shell: bash | ||
run: docker compose -f ./apps/relay/docker-compose.yml up --build --detach redis | ||
|
||
- name: Run tests | ||
run: yarn test:ci | ||
|
||
- name: Upload coverage results | ||
uses: codecov/codecov-action@v3 |
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,21 @@ | ||
name: Label Issues | ||
|
||
on: | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
label_issues: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add label | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
github.rest.issues.addLabels({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ['s-triage'] | ||
}) |
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,42 @@ | ||
# Logs | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.DS_Store | ||
**/.DS_Store | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
build | ||
.history | ||
.hub_history | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Environment variables | ||
.env | ||
|
||
.eslintcache | ||
depot.json | ||
|
||
.console-history | ||
|
||
# Code Coverage Reports | ||
coverage/ | ||
|
||
# Turborepo | ||
.turbo | ||
out | ||
|
||
dist | ||
|
||
# Editor Cache | ||
.vscode | ||
.idea | ||
.fleet | ||
**/.vitepress/cache/ | ||
**/.vitepress/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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint-staged |
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 @@ | ||
registry: https://registry.npmjs.org/ |
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 @@ | ||
.env |
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,21 @@ | ||
{ | ||
"$schema": "../../node_modules/@biomejs/biome/configuration_schema.json", | ||
"organizeImports": { | ||
"enabled": false | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"indentSize": 2, | ||
"indentStyle": "space", | ||
"lineWidth": 120 | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"complexity": { | ||
"useLiteralKeys": "off" | ||
} | ||
} | ||
} | ||
} |
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,20 @@ | ||
version: "3.9" | ||
|
||
services: | ||
redis: | ||
image: "redis:7.2-alpine" | ||
restart: unless-stopped | ||
command: --save 1 1 --loglevel warning --maxmemory-policy noeviction | ||
volumes: | ||
- redis-data:/data | ||
ports: | ||
- "6379:6379" | ||
healthcheck: | ||
test: ["CMD-SHELL", "redis-cli", "ping"] | ||
interval: 10s | ||
timeout: 10s | ||
retries: 3 | ||
start_period: 5s | ||
|
||
volumes: | ||
redis-data: |
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,10 @@ | ||
import { FastifyRequest as DefaultFastifyRequest } from "fastify"; | ||
import { RelaySession } from "./src/handlers"; | ||
import { ChannelStore } from "./src/channels"; | ||
|
||
declare module "fastify" { | ||
export interface FastifyRequest extends DefaultFastifyRequest { | ||
channelToken: string; | ||
channels: ChannelStore<RelaySession>; | ||
} | ||
} |
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,21 @@ | ||
import type { Config } from "jest"; | ||
|
||
const jestConfig: Config = { | ||
testEnvironment: "node", | ||
coveragePathIgnorePatterns: ["<rootDir>/build/", "<rootDir>/node_modules/"], | ||
testPathIgnorePatterns: ["<rootDir>/build", "<rootDir>/node_modules"], | ||
extensionsToTreatAsEsm: [".ts"], | ||
moduleNameMapper: { | ||
"^(\\.{1,2}/.*)\\.js$": "$1", | ||
}, | ||
/** | ||
* For high performance with minimal configuration transform with TS with swc. | ||
* @see https://github.com/farcasterxyz/hub/issues/314 | ||
*/ | ||
transform: { | ||
"^.+\\.(t|j)sx?$": "@swc/jest", | ||
}, | ||
maxWorkers: "50%", | ||
}; | ||
|
||
export default jestConfig; |
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": "@farcaster/connect-relay", | ||
"version": "0.0.1", | ||
"description": "Farcaster Connect relay server", | ||
"private": true, | ||
"type": "commonjs", | ||
"scripts": { | ||
"build": "tsc --project ./tsconfig.json", | ||
"lint": "biome format src/ --write && biome check src/ --apply", | ||
"lint:ci": "biome ci src/", | ||
"test": "yarn build && jest", | ||
"test:ci": "yarn build && ENVIRONMENT=test NODE_OPTIONS=\"--experimental-vm-modules --max-old-space-size=4096\" jest --ci --forceExit --coverage", | ||
"start": "yarn build && node build/app.js start" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"dependencies": { | ||
"@farcaster/hub-nodejs": "^0.10.19", | ||
"@fastify/cors": "^8.4.2", | ||
"dotenv": "^16.3.1", | ||
"ethers": "^6.9.0", | ||
"fastify": "^4.24.3", | ||
"ioredis": "^5.3.2", | ||
"neverthrow": "^6.1.0", | ||
"siwe": "^2.1.4" | ||
}, | ||
"devDependencies": { | ||
"axios": "^1.6.2", | ||
"jest": "^29.7.0" | ||
} | ||
} |
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 @@ | ||
import { RelayServer } from "./server"; | ||
import { CHANNEL_TTL, REDIS_URL, RELAY_SERVER_HOST, RELAY_SERVER_PORT } from "./env"; | ||
|
||
new RelayServer({ | ||
redisUrl: REDIS_URL, | ||
ttl: CHANNEL_TTL, | ||
corsOrigin: "*", | ||
}).start(RELAY_SERVER_HOST, RELAY_SERVER_PORT); |
Oops, something went wrong.