@hasna/shortlinks 0.1.7 → 0.1.9
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 +10 -3
- package/infra/aws-ec2-user-data.sh +4 -36
- package/package.json +2 -2
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -3944
- package/dist/cloudflare.d.ts +0 -43
- package/dist/cloudflare.js +0 -168
- package/dist/config.d.ts +0 -20
- package/dist/database.d.ts +0 -11
- package/dist/domains-cli.d.ts +0 -10
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -877
- package/dist/local.d.ts +0 -27
- package/dist/machine.d.ts +0 -1
- package/dist/pg-migrations.d.ts +0 -1
- package/dist/server.d.ts +0 -12
- package/dist/server.js +0 -611
- package/dist/slug.d.ts +0 -4
- package/dist/store.d.ts +0 -30
- package/dist/types.d.ts +0 -90
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
CLI-only shortlink management for custom domains.
|
|
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, `@hasna/domains`, and `@hasna/cloud` sync.
|
|
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, `@hasna/domains`, and `@hasna/cloud` sync. Production serving can run directly against the shared RDS database with `--cloud`; local SQLite is only for explicit local/offline use.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/@hasna/shortlinks)
|
|
8
8
|
[](LICENSE)
|
|
@@ -64,6 +64,7 @@ shortlinks link enable home --domain has.na
|
|
|
64
64
|
shortlinks stats home --domain has.na
|
|
65
65
|
|
|
66
66
|
shortlinks serve --port 8787
|
|
67
|
+
shortlinks serve --cloud --port 8787
|
|
67
68
|
shortlinks doctor
|
|
68
69
|
```
|
|
69
70
|
|
|
@@ -137,15 +138,21 @@ shortlinks cloud sync
|
|
|
137
138
|
```
|
|
138
139
|
|
|
139
140
|
The cloud database service name is `shortlinks`.
|
|
141
|
+
Use direct RDS mode for production and live management:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
shortlinks --cloud create https://example.com
|
|
145
|
+
shortlinks --cloud link list
|
|
146
|
+
shortlinks serve --cloud --host 127.0.0.1 --port 8787
|
|
147
|
+
```
|
|
140
148
|
|
|
141
149
|
## AWS Origin
|
|
142
150
|
|
|
143
151
|
For an apex domain that needs stable A records, `infra/aws-ec2-user-data.sh` bootstraps a small EC2 redirect origin with:
|
|
144
152
|
|
|
145
153
|
- `@hasna/shortlinks` installed through Bun
|
|
146
|
-
-
|
|
154
|
+
- direct reads and click writes against the `shortlinks` RDS database through `@hasna/cloud`
|
|
147
155
|
- Caddy terminating HTTPS and proxying to `shortlinks serve`
|
|
148
|
-
- a systemd timer that syncs links and clicks every minute
|
|
149
156
|
|
|
150
157
|
The script reads the RDS password from AWS Secrets Manager through the instance role; it does not contain secret values.
|
|
151
158
|
|
|
@@ -64,9 +64,7 @@ RUNNER
|
|
|
64
64
|
chmod 750 /usr/local/bin/shortlinks-env-exec
|
|
65
65
|
chown root:shortlinks /usr/local/bin/shortlinks-env-exec
|
|
66
66
|
|
|
67
|
-
su -s /bin/bash shortlinks -c '/
|
|
68
|
-
su -s /bin/bash shortlinks -c '/usr/local/bin/shortlinks-env-exec shortlinks --json config set default-domain has.na'
|
|
69
|
-
su -s /bin/bash shortlinks -c '/usr/local/bin/shortlinks-env-exec shortlinks --json cloud pull --tables domains,links,clicks' || true
|
|
67
|
+
su -s /bin/bash shortlinks -c 'PATH=/var/lib/shortlinks/.bun/bin:$PATH shortlinks --version'
|
|
70
68
|
|
|
71
69
|
caddy_version="$(curl -fsSL https://api.github.com/repos/caddyserver/caddy/releases/latest | jq -r '.tag_name // "v2.10.2"' | sed 's/^v//')"
|
|
72
70
|
case "$(uname -m)" in
|
|
@@ -92,8 +90,8 @@ Group=shortlinks
|
|
|
92
90
|
WorkingDirectory=/var/lib/shortlinks
|
|
93
91
|
Environment=HOME=/var/lib/shortlinks
|
|
94
92
|
Environment=PATH=/var/lib/shortlinks/.bun/bin:/usr/local/bin:/usr/bin:/bin
|
|
95
|
-
|
|
96
|
-
ExecStart=/usr/local/bin/shortlinks-env-exec shortlinks serve --host 127.0.0.1 --port 8787 --default-host has.na
|
|
93
|
+
Environment=SHORTLINKS_STORE=cloud
|
|
94
|
+
ExecStart=/usr/local/bin/shortlinks-env-exec shortlinks serve --cloud --host 127.0.0.1 --port 8787 --default-host has.na
|
|
97
95
|
Restart=always
|
|
98
96
|
RestartSec=5
|
|
99
97
|
|
|
@@ -101,35 +99,6 @@ RestartSec=5
|
|
|
101
99
|
WantedBy=multi-user.target
|
|
102
100
|
SERVICE
|
|
103
101
|
|
|
104
|
-
cat > /etc/systemd/system/shortlinks-sync.service <<'SERVICE'
|
|
105
|
-
[Unit]
|
|
106
|
-
Description=Sync shortlinks SQLite data with RDS
|
|
107
|
-
After=network-online.target
|
|
108
|
-
Wants=network-online.target
|
|
109
|
-
|
|
110
|
-
[Service]
|
|
111
|
-
Type=oneshot
|
|
112
|
-
User=shortlinks
|
|
113
|
-
Group=shortlinks
|
|
114
|
-
WorkingDirectory=/var/lib/shortlinks
|
|
115
|
-
Environment=HOME=/var/lib/shortlinks
|
|
116
|
-
Environment=PATH=/var/lib/shortlinks/.bun/bin:/usr/local/bin:/usr/bin:/bin
|
|
117
|
-
ExecStart=/usr/local/bin/shortlinks-env-exec shortlinks --json cloud sync --tables domains,links,clicks
|
|
118
|
-
SERVICE
|
|
119
|
-
|
|
120
|
-
cat > /etc/systemd/system/shortlinks-sync.timer <<'TIMER'
|
|
121
|
-
[Unit]
|
|
122
|
-
Description=Run shortlinks cloud sync every minute
|
|
123
|
-
|
|
124
|
-
[Timer]
|
|
125
|
-
OnBootSec=2min
|
|
126
|
-
OnUnitActiveSec=1min
|
|
127
|
-
Unit=shortlinks-sync.service
|
|
128
|
-
|
|
129
|
-
[Install]
|
|
130
|
-
WantedBy=timers.target
|
|
131
|
-
TIMER
|
|
132
|
-
|
|
133
102
|
cat > /etc/systemd/system/caddy.service <<'SERVICE'
|
|
134
103
|
[Unit]
|
|
135
104
|
Description=Caddy web server for shortlinks
|
|
@@ -162,7 +131,6 @@ has.na {
|
|
|
162
131
|
CADDY
|
|
163
132
|
|
|
164
133
|
systemctl daemon-reload
|
|
165
|
-
systemctl enable shortlinks.service
|
|
134
|
+
systemctl enable shortlinks.service caddy.service
|
|
166
135
|
systemctl start shortlinks.service
|
|
167
|
-
systemctl start shortlinks-sync.timer
|
|
168
136
|
systemctl start caddy.service || true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/shortlinks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "CLI-only shortlink manager for custom domains, click tracking, Cloudflare setup, and @hasna cloud sync",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"SECURITY.md"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "rm -rf dist && bun build src/cli/index.ts --outdir dist/cli --target bun --external @hasna/cloud && bun build src/index.ts --outdir dist --target bun --external @hasna/cloud && bun build src/server.ts --outdir dist --target bun && bun build src/cloudflare.ts --outdir dist --target bun && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
|
|
34
|
+
"build": "rm -rf dist && bun build src/cli/index.ts --outdir dist/cli --target bun --external @hasna/cloud && bun build src/index.ts --outdir dist --target bun --external @hasna/cloud && bun build src/server.ts --outdir dist --target bun --external @hasna/cloud && bun build src/cloudflare.ts --outdir dist --target bun && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
|
|
35
35
|
"typecheck": "tsc --noEmit",
|
|
36
36
|
"test": "bun test",
|
|
37
37
|
"dev:cli": "bun run src/cli/index.ts",
|
package/dist/cli/index.d.ts
DELETED