Skip to content

Commit 221b82b

Browse files
committed
Merge remote-tracking branch 'origin/main' into web
2 parents f9eb19c + 0a55ed1 commit 221b82b

8 files changed

Lines changed: 53 additions & 157 deletions

File tree

.env.example

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ DEEPLINK_SQLITE_DSN=deeplink.db
88
# Only used when DEEPLINK_STORE=redis.
99
DEEPLINK_REDIS_ADDR=localhost:6379
1010
DEEPLINK_REDIS_PASSWORD=
11-
# Comma-separated origins allowed to call the JSON API from a browser.
11+
12+
# Comma-separated origins for the dashboard SPA.
1213
DEEPLINK_ALLOWED_ORIGINS=http://localhost:5173
1314
DEEPLINK_TEMPLATE_DIR=
1415
DEEPLINK_SKIP_PATHS_FILE=
@@ -27,5 +28,5 @@ DEEPLINK_API_KEY=
2728
# DEEPLINK_TWITTER_SITE=@example
2829
# DEEPLINK_FEDIVERSE_CREATOR=@user@instance.tld
2930

30-
# Vite (repo-root .env). Keep in sync with DEEPLINK_LISTEN_ADDR.
31+
# Browser → API origin for the SPA (dev proxy + production build).
3132
VITE_API_URL=http://localhost:8090

.github/workflows/ci-web.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI Web
2+
3+
on:
4+
push:
5+
branches: [web]
6+
pull_request:
7+
branches: [web]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ci-web-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
web:
18+
runs-on: ubuntu-latest
19+
defaults:
20+
run:
21+
working-directory: web
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: "22"
28+
cache: npm
29+
cache-dependency-path: web/package-lock.json
30+
31+
- name: Install
32+
run: npm ci
33+
34+
- name: Build (typecheck + bundle)
35+
run: npm run build

.github/workflows/ci.yml

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,13 @@ on:
77

88
permissions:
99
contents: read
10-
pull-requests: read
1110

1211
concurrency:
1312
group: ci-${{ github.workflow }}-${{ github.ref }}
1413
cancel-in-progress: true
1514

1615
jobs:
17-
changes:
18-
runs-on: ubuntu-latest
19-
outputs:
20-
go: ${{ steps.filter.outputs.go }}
21-
web: ${{ steps.filter.outputs.web }}
22-
steps:
23-
- uses: actions/checkout@v4
24-
- uses: dorny/paths-filter@v3
25-
id: filter
26-
with:
27-
filters: |
28-
go:
29-
- '**/*.go'
30-
- 'go.mod'
31-
- 'go.sum'
32-
- '.golangci.yaml'
33-
- '.github/workflows/ci.yml'
34-
web:
35-
- 'web/**'
36-
- '.github/workflows/ci.yml'
37-
3816
test:
39-
needs: changes
40-
if: needs.changes.outputs.go == 'true'
4117
runs-on: ubuntu-latest
4218
steps:
4319
- uses: actions/checkout@v4
@@ -54,25 +30,3 @@ jobs:
5430

5531
- name: Test
5632
run: go test -race -count=1 ./...
57-
58-
web:
59-
needs: changes
60-
if: needs.changes.outputs.web == 'true'
61-
runs-on: ubuntu-latest
62-
defaults:
63-
run:
64-
working-directory: web
65-
steps:
66-
- uses: actions/checkout@v4
67-
68-
- uses: actions/setup-node@v4
69-
with:
70-
node-version: "22"
71-
cache: npm
72-
cache-dependency-path: web/package-lock.json
73-
74-
- name: Install
75-
run: npm ci
76-
77-
- name: Build (typecheck + bundle)
78-
run: npm run build

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ seed.sh
1212
/cmd/deeplink/deeplink
1313
/example/custom/custom
1414

15-
# Dashboard SPA
15+
# Dashboard SPA (this branch)
1616
/web/node_modules
1717
/web/dist
1818
/web/*.log
1919
.env*.local
20+
2021
*.db
2122
*.db-shm
2223
*.db-wal

README.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ See [example/custom](example/custom/) for a working custom processor with tests.
6767

6868
## Standalone server
6969

70-
A ready-to-run Redis-backed server is included:
70+
SQLite by default (zero infra). Redis is optional for multi-instance setups:
7171

7272
```bash
73-
docker compose up -d
7473
go run ./cmd/deeplink
74+
75+
# Redis:
76+
docker compose up -d
77+
DEEPLINK_STORE=redis go run ./cmd/deeplink
7578
```
7679

7780
## Stores
@@ -205,24 +208,15 @@ are omitted, so scrapers never see `content=""`.
205208
Pages also emit `robots: noindex,follow` so short links don't compete with
206209
the destination URL in search.
207210

208-
## Dashboard
209-
210-
A React + TypeScript dashboard lives in [`web/`](web/), configured by
211-
`VITE_API_URL` (see [`.env.example`](.env.example)).
212-
213-
```bash
214-
cd web && npm install && npm run dev # http://localhost:5173
215-
```
211+
## Dashboard / site UI
216212

217-
It reads the API key from `localStorage` (`deeplink.apiKey`) and sends it as
218-
`X-API-Key`, so set `DEEPLINK_API_KEY` to enforce auth. For a cross-origin
219-
deploy, add the origin to `DEEPLINK_ALLOWED_ORIGINS`.
213+
The React landing page and demo dashboard live on the [`web`](https://github.com/yinebebt/deeplink/tree/web) branch (not in `main`). Build and deploy that SPA separately against this API. Set `DEEPLINK_ALLOWED_ORIGINS` (and `DEEPLINK_API_KEY` for mutating routes) when the UI is cross-origin.
220214

221215
## Development
222216

223217
```bash
224218
go test ./... # run tests
225-
go run ./cmd/deeplink # run standalone server (needs Redis)
219+
go run ./cmd/deeplink # standalone server (SQLite by default)
226220
```
227221

228222
## License

cmd/migrate/main.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

server.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@ func (s *Service) handleLinkDetail(w http.ResponseWriter, r *http.Request) {
286286
s.config.Logger.Info("link detail fetched", "shortID", shortID, "duration", time.Since(start).String())
287287
}
288288

289-
// linkListAllCap bounds GET /links so a runaway store cannot OOM the
290-
// dashboard. The dashboard is a single-page view, not a paginated API.
289+
// linkListAllCap bounds GET /links so a runaway store cannot OOM clients
290+
// that load the full list (e.g. the dashboard on the web branch).
291291
const linkListAllCap = 500
292292

293293
// handleLinkListAll returns every non-deleted link across all registered
294-
// types. The dashboard SPA uses this as its single data source.
294+
// types (full list, not a paginated API).
295295
func (s *Service) handleLinkListAll(w http.ResponseWriter, r *http.Request) {
296296
start := time.Now()
297297

@@ -449,8 +449,7 @@ func (s *Service) handleWellKnown(w http.ResponseWriter, r *http.Request) {
449449
http.ServeFile(w, r, filePath)
450450
}
451451

452-
// handleTypes returns all registered processor type names for the
453-
// dashboard's create-form dropdown.
452+
// handleTypes returns registered processor type names (e.g. for create forms).
454453
func (s *Service) handleTypes(w http.ResponseWriter, _ *http.Request) {
455454
respondJSON(w, http.StatusOK, s.registry.Types())
456455
}

web/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const repoRoot = path.resolve(__dirname, "..");
66

77
export default defineConfig(({ mode }) => {
88
const env = loadEnv(mode, repoRoot, "");
9-
const apiURL = env.VITE_API_URL || "http://localhost:8091";
9+
const apiURL = env.VITE_API_URL || "http://localhost:8090";
1010

1111
// GET/HEAD stay on Vite (SPA assets); other methods proxy to the Go API
1212
// so PATCH/DELETE /{shortID} don't collide with the root SPA route.

0 commit comments

Comments
 (0)