Skip to content

Commit 53379bc

Browse files
committed
Update for latest code.
1 parent c2eabe9 commit 53379bc

File tree

7 files changed

+2450
-1225
lines changed

7 files changed

+2450
-1225
lines changed

components/log-viewer-webui/server/package-lock.json

+2,402-871
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/log-viewer-webui/server/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
"@aws-sdk/s3-request-presigner": "^3.731.1",
2121
"@fastify/mongodb": "^9.0.2",
2222
"@fastify/mysql": "^5.0.2",
23-
"@fastify/static": "^8.0.4",
23+
"@fastify/static": "^8.1.1",
2424
"@fastify/type-provider-typebox": "^5.1.0",
25-
"@msgpack/msgpack": "^3.0.0-beta2",
26-
"@sinclair/typebox": "^0.34.14",
27-
"@types/node": "^22.10.7",
25+
"@msgpack/msgpack": "^3.0.1",
26+
"@sinclair/typebox": "^0.34.25",
27+
"@types/node": "^22.13.4",
2828
"dotenv": "^16.4.7",
2929
"fastify": "^5.2.1",
3030
"fastify-plugin": "^5.0.1",
@@ -36,6 +36,6 @@
3636
"concurrently": "^9.1.2",
3737
"eslint-config-yscope": "latest",
3838
"nodemon": "^3.1.9",
39-
"tap": "^21.0.1"
39+
"tap": "^21.0.2"
4040
}
4141
}

components/log-viewer-webui/server/src/DbManager.js

-278
This file was deleted.

components/log-viewer-webui/server/src/DbManager.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
ResultSetHeader,
1616
} from "mysql2/promise";
1717

18+
import {Nullable} from "./typings/common.js";
1819
import {
1920
QUERY_JOB_STATUS,
2021
QUERY_JOB_STATUS_WAITING_STATES,
@@ -209,7 +210,7 @@ class DbManager {
209210
* @return A promise that resolves to the extracted stream's metadata.
210211
*/
211212
async getExtractedStreamFileMetadata (streamId: string, logEventIdx: number)
212-
: Promise<StreamFileMongoDocument | null> {
213+
: Promise<Nullable<StreamFileMongoDocument>> {
213214
return await this.#streamFilesCollection.findOne({
214215
stream_id: streamId,
215216
begin_msg_ix: {$lte: logEventIdx},

components/log-viewer-webui/server/src/S3Manager.js components/log-viewer-webui/server/src/S3Manager.ts

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import fastifyPlugin from "fastify-plugin";
2-
31
import {
42
GetObjectCommand,
53
S3Client,
64
} from "@aws-sdk/client-s3";
75
import {getSignedUrl} from "@aws-sdk/s3-request-presigner";
6+
import fastifyPlugin from "fastify-plugin";
7+
8+
import {Nullable} from "./typings/common.js";
89

910

1011
/**
@@ -16,12 +17,12 @@ const PRE_SIGNED_URL_EXPIRY_TIME_SECONDS = 3600;
1617
* Class to manage Simple Storage Service (S3) objects.
1718
*/
1819
class S3Manager {
19-
#s3Client;
20+
readonly #s3Client;
2021

2122
/**
22-
* @param {string} region
23+
* @param region
2324
*/
24-
constructor (region) {
25+
constructor (region: string) {
2526
this.#s3Client = new S3Client({
2627
region: region,
2728
});
@@ -30,11 +31,11 @@ class S3Manager {
3031
/**
3132
* Generates a pre-signed URL for accessing an S3 object.
3233
*
33-
* @param {string} s3UriString The S3 object URI string.
34-
* @return {Promise<string>} The pre-signed URL string.
34+
* @param s3UriString The S3 object URI string.
35+
* @return The pre-signed URL string.
3536
* @throws {Error} If a pre-signed URL couldn't be generated.
3637
*/
37-
async getPreSignedUrl (s3UriString) {
38+
async getPreSignedUrl (s3UriString: string) {
3839
const s3Uri = new URL(s3UriString);
3940
const command = new GetObjectCommand({
4041
Bucket: s3Uri.hostname,
@@ -49,7 +50,10 @@ class S3Manager {
4950
expiresIn: PRE_SIGNED_URL_EXPIRY_TIME_SECONDS,
5051
}
5152
);
52-
} catch (error) {
53+
} catch (error: unknown) {
54+
if (false === error instanceof Error) {
55+
throw error;
56+
}
5357
throw new Error(`Failed to generate pre-signed URL: ${error.message}`);
5458
}
5559
}
@@ -59,12 +63,18 @@ class S3Manager {
5963
* Initializes a Fastify plugin, which decorates the application with an S3 manager at the
6064
* "s3Manager" property when all plugin options are valid.
6165
*/
62-
export default fastifyPlugin(async (app, options) => {
66+
export default fastifyPlugin(async (app, options: {region: Nullable<string>}) => {
6367
const {region} = options;
6468
if (null === region) {
6569
return;
6670
}
6771

6872
console.log(`Initializing S3Manager with region="${region}"...`);
69-
await app.decorate("s3Manager", new S3Manager(region));
73+
app.decorate("s3Manager", new S3Manager(region));
7074
});
75+
76+
declare module "fastify" {
77+
interface FastifyInstance {
78+
s3Manager?: S3Manager;
79+
}
80+
}

0 commit comments

Comments
 (0)