@shetty4l/core 0.1.31 → 0.1.33
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/package.json +1 -1
- package/scripts/install-lib.sh +2 -2
- package/src/http.ts +15 -1
package/package.json
CHANGED
package/scripts/install-lib.sh
CHANGED
|
@@ -54,7 +54,7 @@ fetch_latest_release() {
|
|
|
54
54
|
fi
|
|
55
55
|
|
|
56
56
|
local release_json
|
|
57
|
-
release_json=$(curl -fsSL "${auth_header[@]}" "https://api.github.com/repos/${REPO}/releases/latest")
|
|
57
|
+
release_json=$(curl -fsSL ${auth_header[@]+"${auth_header[@]}"} "https://api.github.com/repos/${REPO}/releases/latest")
|
|
58
58
|
|
|
59
59
|
RELEASE_TAG=$(echo "$release_json" | jq -r '.tag_name')
|
|
60
60
|
TARBALL_URL=$(echo "$release_json" | jq -r ".assets[] | select(.name | startswith(\"${SERVICE_NAME}-\")) | .browser_download_url")
|
|
@@ -89,7 +89,7 @@ download_and_extract() {
|
|
|
89
89
|
info "Downloading ${RELEASE_TAG}..."
|
|
90
90
|
local tmpfile
|
|
91
91
|
tmpfile=$(mktemp)
|
|
92
|
-
curl -fsSL "${auth_header[@]}" -o "$tmpfile" "$TARBALL_URL"
|
|
92
|
+
curl -fsSL ${auth_header[@]+"${auth_header[@]}"} -o "$tmpfile" "$TARBALL_URL"
|
|
93
93
|
|
|
94
94
|
info "Extracting to ${version_dir}..."
|
|
95
95
|
tar xzf "$tmpfile" -C "$version_dir"
|
package/src/http.ts
CHANGED
|
@@ -92,6 +92,11 @@ export interface ServerOpts {
|
|
|
92
92
|
version: string,
|
|
93
93
|
startTime: number,
|
|
94
94
|
) => Response | Promise<Response>;
|
|
95
|
+
/**
|
|
96
|
+
* Maximum seconds a connection may be idle before the server closes it.
|
|
97
|
+
* Passed directly to Bun.serve(). Defaults to Bun's built-in default (10s).
|
|
98
|
+
*/
|
|
99
|
+
idleTimeout?: number;
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
export interface HttpServer {
|
|
@@ -111,13 +116,22 @@ export interface HttpServer {
|
|
|
111
116
|
* 4. If onRequest returns null -> 404
|
|
112
117
|
*/
|
|
113
118
|
export function createServer(opts: ServerOpts): HttpServer {
|
|
114
|
-
const {
|
|
119
|
+
const {
|
|
120
|
+
port,
|
|
121
|
+
host = "127.0.0.1",
|
|
122
|
+
version,
|
|
123
|
+
onRequest,
|
|
124
|
+
onHealth,
|
|
125
|
+
name,
|
|
126
|
+
idleTimeout,
|
|
127
|
+
} = opts;
|
|
115
128
|
const startTime = Date.now();
|
|
116
129
|
const prefix = name ? `${name}: ` : "";
|
|
117
130
|
|
|
118
131
|
const server = Bun.serve({
|
|
119
132
|
port,
|
|
120
133
|
hostname: host,
|
|
134
|
+
...(idleTimeout != null && { idleTimeout }),
|
|
121
135
|
async fetch(req: Request): Promise<Response> {
|
|
122
136
|
const url = new URL(req.url);
|
|
123
137
|
|