@hasna/shortlinks 0.1.13 → 0.1.15
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/cloudflare/shortlinks.js +18 -11
- package/cloudflare/wrangler.example.toml +1 -0
- package/dist/api-client.d.ts +30 -0
- package/dist/cli/index.js +357 -27
- package/dist/cloudflare.d.ts +1 -0
- package/dist/cloudflare.js +19 -11
- package/dist/config.d.ts +8 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +308 -16
- package/dist/server.d.ts +16 -1
- package/dist/server.js +126 -2
- package/dist/storage.js +16 -2
- package/infra/aws-ec2-user-data.sh +28 -1
- package/package.json +1 -1
|
@@ -8,6 +8,8 @@ export RDS_SECRET_ID="${RDS_SECRET_ID:-}"
|
|
|
8
8
|
export RDS_HOST="${RDS_HOST:-}"
|
|
9
9
|
export RDS_USERNAME="${RDS_USERNAME:-}"
|
|
10
10
|
export SHORTLINKS_DOMAIN="${SHORTLINKS_DOMAIN:-}"
|
|
11
|
+
export ATTACHMENTS_ORIGIN="${ATTACHMENTS_ORIGIN:-}"
|
|
12
|
+
export SHORTLINKS_API_PATH_PREFIX="${SHORTLINKS_API_PATH_PREFIX:-/_shortlinks/api}"
|
|
11
13
|
|
|
12
14
|
: "${RDS_SECRET_ID:?Set RDS_SECRET_ID to the AWS Secrets Manager secret for the PostgreSQL database_url}"
|
|
13
15
|
: "${SHORTLINKS_DOMAIN:?Set SHORTLINKS_DOMAIN to the public host served by Caddy}"
|
|
@@ -84,6 +86,7 @@ AWS_REGION=${AWS_REGION}
|
|
|
84
86
|
RDS_SECRET_ID=${RDS_SECRET_ID}
|
|
85
87
|
SHORTLINKS_DOMAIN=${SHORTLINKS_DOMAIN}
|
|
86
88
|
SHORTLINKS_STORE=remote
|
|
89
|
+
SHORTLINKS_API_PATH_PREFIX=${SHORTLINKS_API_PATH_PREFIX}
|
|
87
90
|
SHORTLINKS_ENV
|
|
88
91
|
chmod 640 /etc/default/shortlinks
|
|
89
92
|
chown root:shortlinks /etc/default/shortlinks
|
|
@@ -113,7 +116,7 @@ WorkingDirectory=/var/lib/shortlinks
|
|
|
113
116
|
Environment=HOME=/var/lib/shortlinks
|
|
114
117
|
Environment=PATH=/var/lib/shortlinks/.bun/bin:/usr/local/bin:/usr/bin:/bin
|
|
115
118
|
EnvironmentFile=/etc/default/shortlinks
|
|
116
|
-
ExecStart=/usr/local/bin/shortlinks-env-exec shortlinks serve --remote --host 127.0.0.1 --port 8787 --default-host ${SHORTLINKS_DOMAIN}
|
|
119
|
+
ExecStart=/usr/local/bin/shortlinks-env-exec shortlinks serve --remote --host 127.0.0.1 --port 8787 --default-host ${SHORTLINKS_DOMAIN} --api-path-prefix ${SHORTLINKS_API_PATH_PREFIX}
|
|
117
120
|
Restart=always
|
|
118
121
|
RestartSec=5
|
|
119
122
|
|
|
@@ -145,12 +148,36 @@ WantedBy=multi-user.target
|
|
|
145
148
|
SERVICE
|
|
146
149
|
|
|
147
150
|
install -d /etc/caddy
|
|
151
|
+
if [ -n "${ATTACHMENTS_ORIGIN}" ]; then
|
|
152
|
+
cat > /etc/caddy/Caddyfile <<CADDY
|
|
153
|
+
${SHORTLINKS_DOMAIN} {
|
|
154
|
+
encode zstd gzip
|
|
155
|
+
|
|
156
|
+
handle /a/* {
|
|
157
|
+
reverse_proxy ${ATTACHMENTS_ORIGIN}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
handle /api/* {
|
|
161
|
+
reverse_proxy ${ATTACHMENTS_ORIGIN}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
handle /_shortlinks/* {
|
|
165
|
+
reverse_proxy 127.0.0.1:8787
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
handle {
|
|
169
|
+
reverse_proxy 127.0.0.1:8787
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
CADDY
|
|
173
|
+
else
|
|
148
174
|
cat > /etc/caddy/Caddyfile <<CADDY
|
|
149
175
|
${SHORTLINKS_DOMAIN} {
|
|
150
176
|
encode zstd gzip
|
|
151
177
|
reverse_proxy 127.0.0.1:8787
|
|
152
178
|
}
|
|
153
179
|
CADDY
|
|
180
|
+
fi
|
|
154
181
|
|
|
155
182
|
systemctl daemon-reload
|
|
156
183
|
systemctl enable shortlinks.service caddy.service
|
package/package.json
CHANGED