@hasna/shortlinks 0.1.17 → 0.1.19

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.
@@ -32,7 +32,6 @@ export declare function writeWorkerFiles(options?: {
32
32
  outDir?: string;
33
33
  workerName?: string;
34
34
  origin?: string;
35
- attachmentsOrigin?: string;
36
35
  }): {
37
36
  workerPath: string;
38
37
  wranglerPath: string;
@@ -56,33 +56,17 @@ function generateWorkerScript() {
56
56
  }
57
57
 
58
58
  const incoming = new URL(request.url);
59
- const proxyTo = (targetOrigin, marker) => {
60
- const upstream = new URL(incoming.pathname + incoming.search, targetOrigin);
61
- const headers = new Headers(request.headers);
62
- headers.set("x-forwarded-host", incoming.host);
63
- headers.set("x-shortlinks-worker", marker);
59
+ const upstream = new URL(incoming.pathname + incoming.search, origin);
60
+ const headers = new Headers(request.headers);
61
+ headers.set("x-forwarded-host", incoming.host);
62
+ headers.set("x-shortlinks-worker", "cloudflare");
64
63
 
65
- return fetch(upstream.toString(), {
66
- method: request.method,
67
- headers,
68
- body: request.method === "GET" || request.method === "HEAD" ? undefined : request.body,
69
- redirect: "manual"
70
- });
71
- };
72
-
73
- const reserved = (env.SHORTLINKS_RESERVED_PATH_PREFIXES || "a")
74
- .split(",")
75
- .map((value) => value.trim().toLowerCase())
76
- .filter(Boolean);
77
- const firstSegment = decodeURIComponent(incoming.pathname.replace(/^\\/+/, "").split("/")[0] || "").toLowerCase();
78
- if (firstSegment && reserved.includes(firstSegment)) {
79
- if (env.ATTACHMENTS_ORIGIN) {
80
- return proxyTo(env.ATTACHMENTS_ORIGIN, "attachments");
81
- }
82
- return new Response("Reserved path prefix", { status: 404 });
83
- }
84
-
85
- return proxyTo(origin, "cloudflare");
64
+ return fetch(upstream.toString(), {
65
+ method: request.method,
66
+ headers,
67
+ body: request.method === "GET" || request.method === "HEAD" ? undefined : request.body,
68
+ redirect: "manual"
69
+ });
86
70
  }
87
71
  };
88
72
  `;
@@ -100,8 +84,6 @@ compatibility_date = "2026-05-01"
100
84
 
101
85
  [vars]
102
86
  SHORTLINKS_ORIGIN = "${options.origin || "https://shortlinks.example.com"}"
103
- ATTACHMENTS_ORIGIN = "${options.attachmentsOrigin || ""}"
104
- SHORTLINKS_RESERVED_PATH_PREFIXES = "a"
105
87
  `);
106
88
  return { workerPath, wranglerPath };
107
89
  }
package/dist/config.d.ts CHANGED
@@ -3,12 +3,6 @@ export declare const DEFAULT_DATA_DIR: string;
3
3
  export interface ShortlinksConfig {
4
4
  defaultDomain?: string;
5
5
  publicBaseUrl?: string;
6
- mode?: "local" | "remote" | "api";
7
- api?: {
8
- baseUrl?: string;
9
- token?: string;
10
- tokenEnv?: string;
11
- };
12
6
  cloudflare?: {
13
7
  accountId?: string;
14
8
  workerName?: string;
@@ -22,7 +16,5 @@ export declare function getDatabasePath(explicitPath?: string): string;
22
16
  export declare function loadConfig(): ShortlinksConfig;
23
17
  export declare function saveConfig(config: ShortlinksConfig): void;
24
18
  export declare function updateConfig(patch: ShortlinksConfig): ShortlinksConfig;
25
- export declare function getApiBaseUrl(config?: ShortlinksConfig): string | null;
26
- export declare function getApiToken(config?: ShortlinksConfig): string | null;
27
19
  export declare function normalizeHostname(input: string): string;
28
20
  export declare function formatShortUrl(hostname: string, slug: string, publicBaseUrl?: string): string;
package/dist/index.d.ts CHANGED
@@ -1,17 +1,10 @@
1
1
  export { ShortlinksDatabase, SQLITE_MIGRATIONS, makeId, now } from "./database.js";
2
2
  export { ShortlinksStore } from "./store.js";
3
3
  export { PgShortlinksStore } from "./pg-store.js";
4
- export { CANONICAL_SHORTLINKS_RDS_CLUSTER, CANONICAL_SHORTLINKS_RDS_DATABASE, CANONICAL_SHORTLINKS_RDS_SECRET_PATH, SHORTLINKS_STORAGE_ENV, SHORTLINKS_STORAGE_FALLBACK_ENV, SHORTLINKS_STORAGE_MODE_ENV, SHORTLINKS_STORAGE_MODE_FALLBACK_ENV, STORAGE_DATABASE_ENV, STORAGE_MODE_ENV, getConnectionString, getCanonicalShortlinksRdsConfig, getStorageDatabaseEnv, getStorageDatabaseEnvName, getStorageConfig, getStorageConnectionString, getStorageDatabaseUrl, } from "./storage-config.js";
5
- export type { CanonicalShortlinksRdsConfig, StorageConfig, StorageEnv, StorageMode } from "./storage-config.js";
6
- export { PgAdapterAsync } from "./remote-storage.js";
7
- export { applyPgMigrations } from "./pg-migrate.js";
8
- export { SHORTLINKS_STORAGE_TABLES, STORAGE_TABLES, getStoragePg, getStorageStatus, parseStorageTables, pullStorageChanges, pushStorageChanges, runStorageMigrations, syncStorageChanges, } from "./storage-sync.js";
9
- export type { StorageStatus, StorageSyncResult, SyncResult } from "./storage-sync.js";
10
4
  export { createShortlinksHandler, serveShortlinks } from "./server.js";
11
- export { ShortlinksApiClient } from "./api-client.js";
12
5
  export { createCloudflarePlan, generateWorkerScript, writeWorkerFiles, upsertCloudflareDnsRecord } from "./cloudflare.js";
13
6
  export { createLocalSetupPlan, registerMachinesDns } from "./local.js";
14
7
  export { PG_MIGRATIONS } from "./pg-migrations.js";
15
- export { formatShortUrl, getApiBaseUrl, getApiToken, getConfigPath, getDataDir, getDatabasePath, loadConfig, normalizeHostname, saveConfig } from "./config.js";
8
+ export { formatShortUrl, getConfigPath, getDataDir, getDatabasePath, loadConfig, normalizeHostname, saveConfig } from "./config.js";
16
9
  export { normalizeSlug, randomToken } from "./slug.js";
17
10
  export type { AddDomainInput, Click, ClickInput, CreateLinkInput, Domain, Link, LinkStats } from "./types.js";