anbaric-cloud-hosting 1.22.0 → 1.23.0
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anbaric-cloud-hosting",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "Anbaric Cloud hosting service: Postgres-backed job persistence and queuing exposed over an HTTP API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "chris@anbaric.ai",
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"@aws-sdk/client-s3": "^3.1110.0",
|
|
19
19
|
"@aws-sdk/client-secrets-manager": "^3.700.0",
|
|
20
20
|
"@aws-sdk/client-servicediscovery": "^3.1110.0",
|
|
21
|
-
"anbaric-data-store": "^1.
|
|
22
|
-
"anbaric-plugins": "^1.
|
|
23
|
-
"anbaric-tsapi": "^1.
|
|
24
|
-
"anbaric-web": "^1.
|
|
21
|
+
"anbaric-data-store": "^1.23.0",
|
|
22
|
+
"anbaric-plugins": "^1.23.0",
|
|
23
|
+
"anbaric-tsapi": "^1.23.0",
|
|
24
|
+
"anbaric-web": "^1.23.0",
|
|
25
25
|
"esbuild": "^0.28.2",
|
|
26
26
|
"pg": "^8.16.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.2.0",
|
|
30
30
|
"@types/pg": "^8.15.0",
|
|
31
|
-
"anbaric-impl-cloud": "^1.
|
|
32
|
-
"anbaric-state-machine": "^1.
|
|
31
|
+
"anbaric-impl-cloud": "^1.23.0",
|
|
32
|
+
"anbaric-state-machine": "^1.23.0",
|
|
33
33
|
"tsx": "^4.20.0",
|
|
34
34
|
"typescript": "^7.0.2"
|
|
35
35
|
},
|
|
@@ -17,6 +17,7 @@ import {WhoamiHandler} from "./handlers/auth/WhoamiHandler";
|
|
|
17
17
|
import {ConsumersHandler} from "./handlers/ConsumersHandler";
|
|
18
18
|
import {DocumentsHandler} from "./handlers/DocumentsHandler";
|
|
19
19
|
import {JobsHandler} from "./handlers/JobsHandler";
|
|
20
|
+
import {FaviconHandler} from "./handlers/FaviconHandler";
|
|
20
21
|
import {PagesHandler} from "./handlers/PagesHandler";
|
|
21
22
|
import {PingHandler} from "./handlers/PingHandler";
|
|
22
23
|
import {QueueHandler} from "./handlers/QueueHandler";
|
|
@@ -67,6 +68,7 @@ class HostingServer {
|
|
|
67
68
|
const publicRouter = new Router();
|
|
68
69
|
publicRouter.registerRoot(pages);
|
|
69
70
|
publicRouter.register("ping", ping);
|
|
71
|
+
publicRouter.register("favicon.ico", new FaviconHandler());
|
|
70
72
|
if (plugins.length > 0) publicRouter.registerApi("plugins", new PluginsHandler(plugins));
|
|
71
73
|
publicRouter.registerApi("whoami", new WhoamiHandler());
|
|
72
74
|
publicRouter.registerApi("sessions", sessions);
|
package/src/hosting/Request.ts
CHANGED
|
@@ -111,6 +111,14 @@ class Request {
|
|
|
111
111
|
this.response.end(script);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
replyImage(image : Buffer, contentType : string, cacheSeconds : number = 0) : void {
|
|
115
|
+
this.response.writeHead(200, {
|
|
116
|
+
"content-type": contentType,
|
|
117
|
+
...(cacheSeconds > 0 ? { "cache-control": `public, max-age=${cacheSeconds}` } : {}),
|
|
118
|
+
});
|
|
119
|
+
this.response.end(image);
|
|
120
|
+
}
|
|
121
|
+
|
|
114
122
|
redirect(location : string, status : number = 302, headers : Record<string, string> = {}) : void {
|
|
115
123
|
this.response.writeHead(status, { location, ...headers });
|
|
116
124
|
this.response.end();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {readFile} from "node:fs/promises";
|
|
2
|
+
import {Request} from "../Request";
|
|
3
|
+
import {RequestHandler} from "../RequestHandler";
|
|
4
|
+
|
|
5
|
+
const CACHE_SECONDS = 86_400;
|
|
6
|
+
|
|
7
|
+
/* Serves the Anbaric ident at /favicon.ico for everything the platform fronts.
|
|
8
|
+
The admin console asks for it explicitly; a deployed app served under
|
|
9
|
+
/app/<name> gets it for free, because a browser falls back to the origin root
|
|
10
|
+
when the app's own pages declare no icon. */
|
|
11
|
+
class FaviconHandler implements RequestHandler {
|
|
12
|
+
|
|
13
|
+
private icon? : Buffer;
|
|
14
|
+
|
|
15
|
+
async handle(request : Request) : Promise<void> {
|
|
16
|
+
if (request.method !== "GET") return request.notFound();
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
request.replyImage(await this.load(), "image/png", CACHE_SECONDS);
|
|
20
|
+
} catch {
|
|
21
|
+
request.notFound();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private async load() : Promise<Buffer> {
|
|
26
|
+
if (!this.icon) this.icon = await readFile(new URL("../pages/anbaric-favicon.png", import.meta.url));
|
|
27
|
+
return this.icon;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { FaviconHandler }
|
|
Binary file
|