Skip to content

Commit

Permalink
Merge pull request #1 from open-frames/nm/initial-commit
Browse files Browse the repository at this point in the history
Create Open Frames Proxy
  • Loading branch information
neekolas authored Feb 14, 2024
2 parents 631c755 + e8ffe6d commit 389b8d3
Show file tree
Hide file tree
Showing 22 changed files with 5,453 additions and 2 deletions.
Binary file added .DS_Store
Binary file not shown.
135 changes: 135 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# flyctl launch added from .gitignore
# Logs
**/logs
**/*.log
**/npm-debug.log*
**/yarn-debug.log*
**/yarn-error.log*
**/lerna-debug.log*
**/.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
**/report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
**/pids
**/*.pid
**/*.seed
**/*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
**/lib-cov

# Coverage directory used by tools like istanbul
**/coverage
**/*.lcov

# nyc test coverage
**/.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
**/.grunt

# Bower dependency directory (https://bower.io/)
**/bower_components

# node-waf configuration
**/.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
**/build/Release

# Dependency directories
**/node_modules
**/jspm_packages

# Snowpack dependency directory (https://snowpack.dev/)
**/web_modules

# TypeScript cache
**/*.tsbuildinfo

# Optional npm cache directory
**/.npm

# Optional eslint cache
**/.eslintcache

# Optional stylelint cache
**/.stylelintcache

# Microbundle cache
**/.rpt2_cache
**/.rts2_cache_cjs
**/.rts2_cache_es
**/.rts2_cache_umd

# Optional REPL history
**/.node_repl_history

# Output of 'npm pack'
**/*.tgz

# Yarn Integrity file
**/.yarn-integrity

# dotenv environment variable files
**/.env
**/.env.development.local
**/.env.test.local
**/.env.production.local
**/.env.local

# parcel-bundler cache (https://parceljs.org/)
**/.cache
**/.parcel-cache

# Next.js build output
**/.next
**/out

# Nuxt.js build / generate output
**/.nuxt
**/dist

# Gatsby files
**/.cache
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
**/.vuepress/dist

# vuepress v2.x temp and cache directory
**/.temp
**/.cache

# Docusaurus cache and generated files
**/.docusaurus

# Serverless directories
**/.serverless

# FuseBox cache
**/.fusebox

# DynamoDB Local files
**/.dynamodb

# TernJS port file
**/.tern-port

# Stores VSCode versions used for testing VSCode extensions
**/.vscode-test

# yarn v2
**/.yarn/cache
**/.yarn/unplugged
**/.yarn/build-state.yml
**/.yarn/install-state.gz
**/.pnp.*

# Mac OS
**/.DS_STORE
fly.toml
38 changes: 38 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Docker image

on:
push:
branches:
- main

jobs:
push_to_registry:
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
WORKDIR /usr/src/app

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/prod/node_modules node_modules
COPY . .

# [optional] tests & build
ENV NODE_ENV=production

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/src ./src
COPY --from=prerelease /usr/src/app/package.json .

# run the app
USER bun
EXPOSE 8080/tcp
ENTRYPOINT [ "bun", "run", "src/index.ts" ]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 open-frames
Copyright (c) 2024 Nicholas Molnar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# proxy
# OpenGraph Proxy

A simple proxy server to read OpenGraph tags from a URL without revealing client IP addresses. Designed to also support Farcaster Frames.

## Setup

To install dependencies:

```bash
bun install
```

To run:

```bash
bun run src/index.ts
```

This project was created using `bun init` in bun v1.0.25. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
Binary file added bun.lockb
Binary file not shown.
22 changes: 22 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# fly.toml app configuration file generated for open-frames-proxy on 2024-02-14T15:21:00-08:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'open-frames-proxy'
primary_region = 'sea'

[build]

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@xmtp/link-preview-server",
"module": "src/index.ts",
"type": "module",
"scripts": {
"start": "bun run src/index.ts",
"test": "bun test"
},
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"cheerio": "^1.0.0-rc.12"
}
}
7 changes: 7 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const TAG_PREFIXES = ["og:", "fc:", "of:", "xmtp:"] as const;
export const PORT = 8080;
export const CORS_HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "OPTIONS, GET, POST",
"Access-Control-Allow-Headers": "*",
};
3 changes: 3 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export class NoRedirectError extends Error {}

export class InvalidRequestError extends Error {}
Loading

0 comments on commit 389b8d3

Please sign in to comment.