@hasna/shortlinks 0.2.7 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Shortlink management for custom domains — CLI, MCP server, REST API, and a generated SDK.
4
4
 
5
- `shortlinks` creates Bitly-style short URLs, supports multiple domains, records click analytics, can run a tiny redirect server, and includes helper commands for Cloudflare DNS/Workers and `@hasna/domains`. It defaults to local SQLite and can serve from an app-owned PostgreSQL database when `HASNA_SHORTLINKS_STORE=postgres` and `HASNA_SHORTLINKS_DATABASE_URL` are configured.
5
+ `shortlinks` creates Bitly-style short URLs, supports multiple domains, records click analytics, can run a tiny redirect server, and includes helper commands for Cloudflare DNS/Workers and `@hasna/domains`. It defaults to local SQLite and serves from an app-owned PostgreSQL database when `HASNA_SHORTLINKS_DATABASE_URL` is configured.
6
6
 
7
7
  ## Surfaces
8
8
 
@@ -15,19 +15,18 @@ Four surfaces share one core library:
15
15
  | REST API | `shortlinks-serve` | HTTP service: `GET /health`, `/ready`, `/version`, `/openapi.json`, and a versioned `/v1` CRUD API guarded by API-key auth. |
16
16
  | SDK | `@hasna/shortlinks-sdk` (+ `@hasna/shortlinks/sdk`) | Typed fetch client generated from the serve OpenAPI (`bun run sdk:generate`). |
17
17
 
18
- ### Cloud service (PURE REMOTE, Amendment A1)
18
+ ### Hosted service
19
19
 
20
- `shortlinks-serve` reads/writes the shared cloud Postgres directly via the vendored `@hasna/contracts` storage kit — no sync engine or cache in the service. API-key auth comes from `@hasna/contracts/auth`; mint keys with `contracts issue-key --app shortlinks --scopes 'shortlinks:read,shortlinks:write'`.
20
+ `shortlinks-serve` reads/writes PostgreSQL directly via the vendored `@hasna/contracts` storage kit — no sync engine or cache in the service. A configured `HASNA_SHORTLINKS_DATABASE_URL` selects the postgresql server data backend; the pool factory fails closed without it. API-key auth comes from `@hasna/contracts/auth`; mint keys with `contracts issue-key --app shortlinks --scopes 'shortlinks:read,shortlinks:write'`.
21
21
 
22
22
  ```bash
23
- HASNA_SHORTLINKS_STORAGE_MODE=cloud \
24
- HASNA_SHORTLINKS_DATABASE_URL=postgres://user:pass@host:5432/shortlinks?sslmode=require \
23
+ HASNA_SHORTLINKS_DATABASE_URL=$DATABASE_URL \
25
24
  HASNA_SHORTLINKS_API_SIGNING_KEY=... \
26
25
  shortlinks-serve # migrate (idempotent) then serve on :8080
27
26
  shortlinks-serve migrate # one-shot migration task
28
27
  ```
29
28
 
30
- Client self_hosted mode uses `SHORTLINKS_API_URL` + `SHORTLINKS_API_KEY` (never a DSN).
29
+ Clients use `SHORTLINKS_API_URL` + `SHORTLINKS_API_KEY` (never a DSN).
31
30
 
32
31
  [![npm](https://img.shields.io/npm/v/@hasna/shortlinks)](https://www.npmjs.com/package/@hasna/shortlinks)
33
32
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
@@ -161,8 +160,8 @@ Create a dry-run plan:
161
160
 
162
161
  ```bash
163
162
  shortlinks cloudflare plan has.na \
164
- --target shortlinks.hasna.xyz \
165
- --origin https://shortlinks.hasna.xyz
163
+ --target shortlinks.example.com \
164
+ --origin https://shortlinks.example.com
166
165
  ```
167
166
 
168
167
  Write a Cloudflare Worker that forwards requests to the redirect server while preserving the original host:
@@ -170,13 +169,13 @@ Write a Cloudflare Worker that forwards requests to the redirect server while pr
170
169
  ```bash
171
170
  shortlinks cloudflare worker \
172
171
  --worker shortlinks \
173
- --origin https://shortlinks.hasna.xyz
172
+ --origin https://shortlinks.example.com
174
173
  ```
175
174
 
176
175
  Upsert DNS when `CLOUDFLARE_API_TOKEN` is available. Global API key auth is also supported with `CLOUDFLARE_API_KEY` plus `CLOUDFLARE_EMAIL`.
177
176
 
178
177
  ```bash
179
- shortlinks cloudflare dns has.na --target shortlinks.hasna.xyz
178
+ shortlinks cloudflare dns has.na --target shortlinks.example.com
180
179
  ```
181
180
 
182
181
  ## Buying Domains
@@ -190,28 +189,26 @@ shortlinks domain buy new-short-domain.ai --dry-run
190
189
 
191
190
  This package does not install or call any removed `connect-*` packages.
192
191
 
193
- ## Storage modes
192
+ ## Storage selection
194
193
 
195
194
  The client resolves ONE `Store` from the environment — there is no DSN on any client:
196
195
 
197
- - **local** (default): on-box SQLite. Every command, MCP tool, and SDK call reads
198
- and writes the local database.
199
- - **self_hosted / cloud**: set `HASNA_SHORTLINKS_API_URL` + `HASNA_SHORTLINKS_API_KEY`
200
- (and optionally `HASNA_SHORTLINKS_STORAGE_MODE`) to route every call to the cloud
201
- `/v1` HTTP API with a bearer key. `self_hosted` and `cloud` are identical client
202
- code; only the URL/key differ.
196
+ - **on-box SQLite** (default): every command, MCP tool, and SDK call reads and
197
+ writes the local database.
198
+ - **hosted `/v1` HTTP API**: set `HASNA_SHORTLINKS_API_URL` + `HASNA_SHORTLINKS_API_KEY`
199
+ to route every call to the hosted `/v1` API with a bearer key. Setting only one
200
+ of the two is a configuration error and fails loudly never silent local drift.
203
201
 
204
202
  ```bash
205
- # Route the client to the self-hosted cloud API (bearer key, never a DSN):
206
- export HASNA_SHORTLINKS_API_URL=https://shortlinks.hasna.xyz
203
+ # Route the client to the hosted API (bearer key, never a DSN):
204
+ export HASNA_SHORTLINKS_API_URL=https://shortlinks.example.com
207
205
  export HASNA_SHORTLINKS_API_KEY=hsk_...
208
- export HASNA_SHORTLINKS_STORAGE_MODE=self_hosted
209
206
  shortlinks doctor
210
207
  ```
211
208
 
212
- The cloud server (`shortlinks-serve`, run on ECS Fargate) is the only component
213
- that holds a Postgres connection, and it opens its pool server-side through the
214
- sanctioned storage kit — the raw RDS DSN is never distributed to clients.
209
+ The server (`shortlinks-serve`) is the only component that holds a Postgres
210
+ connection, and it opens its pool server-side through the sanctioned storage
211
+ kit — the raw RDS DSN is never distributed to clients.
215
212
 
216
213
  ## Development
217
214
 
@@ -230,7 +227,7 @@ The OSS repository is expected to be:
230
227
  hasna/shortlinks
231
228
  ```
232
229
 
233
- The local workspace folder may still be named `open-shortlinks`; the published package and GitHub repo do not use the `open-` prefix.
230
+ The local workspace folder is named `shortlinks`; the published package and GitHub repo use bare names without the retired `open-` prefix.
234
231
 
235
232
  ## License
236
233
 
@@ -3,4 +3,4 @@ main = "shortlinks.js"
3
3
  compatibility_date = "2026-05-01"
4
4
 
5
5
  [vars]
6
- SHORTLINKS_ORIGIN = "https://shortlinks.hasna.xyz"
6
+ SHORTLINKS_ORIGIN = "https://shortlinks.example.com"