70 lines
1.7 KiB
Markdown
70 lines
1.7 KiB
Markdown
# Bun Forgejo Pages Proxy
|
|
|
|
A simple static page server built with Bun that proxies files from a Forgejo repository.
|
|
|
|
## Features
|
|
|
|
- Serves static files (HTML, CSS, JS, images, etc.) from a `static-pages` branch
|
|
- Automatic `index.html` resolution for directory paths
|
|
- Proper MIME type handling via `mime` package
|
|
- Minimal and fast Bun server
|
|
|
|
## Requirements
|
|
|
|
- [Bun](https://bun.sh/) >= 1.2
|
|
- A Forgejo instance with an API token
|
|
- Repositories with a `static-pages` branch (or any configured via `BRANCH`)
|
|
|
|
## Setup
|
|
|
|
### 1. Clone the repository
|
|
|
|
```bash
|
|
git clone https://git.creations.works/creations/forgejoPages
|
|
cd forgejoPages
|
|
```
|
|
|
|
### 2. Install dependencies
|
|
|
|
```bash
|
|
bun install
|
|
```
|
|
|
|
### 3. Configure environment
|
|
|
|
Copy `.env.example` to `.env` and fill in your Forgejo details:
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
|
|
### 4. Start the server
|
|
|
|
```bash
|
|
bun run dev
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
| Name | Description |
|
|
|-----------------|-----------------------------------------------------|
|
|
| `HOST` | Host to bind the server to |
|
|
| `PORT` | Port to run the server on |
|
|
| `FORGEJO_URL` | URL to your Forgejo instance |
|
|
| `FORGEJO_TOKEN` | Personal access token with repo read access |
|
|
| `BRANCH` | Branch to serve files from (e.g., `static-pages`) |
|
|
| `REPO` | Repository name to use (defaults to `pages`) |
|
|
|
|
## How It Works
|
|
|
|
Requesting `/username/path/to/file` will fetch:
|
|
|
|
```
|
|
https://FORGEJO_URL/api/v1/repos/username/pages/raw/path/to/file?ref=BRANCH
|
|
```
|
|
|
|
If a request ends in `/`, it automatically appends `index.html`.
|
|
|
|
## License
|
|
|
|
[MIT](LICENSE)
|