diff --git a/lib/s3/const.ts b/lib/s3/const.ts index d45fb15d..4bd5f3ac 100644 --- a/lib/s3/const.ts +++ b/lib/s3/const.ts @@ -22,4 +22,4 @@ export const mimeMap: Record = { export const PublicBucketBaseURL = process.env.S3_EXTERNAL_BASE_URL ? `${process.env.S3_EXTERNAL_BASE_URL}/${process.env.S3_PUBLIC_BUCKET}` - : `${process.env.S3_USE_SSL ? 'https' : 'http'}://${process.env.S3_ENDPOINT}/${process.env.S3_PUBLIC_BUCKET}`; + : `${process.env.S3_USE_SSL === 'true' ? 'https' : 'http'}://${process.env.S3_ENDPOINT}:${process.env.S3_PORT}/${process.env.S3_PUBLIC_BUCKET}`; diff --git a/modules/tool/parseMod.ts b/modules/tool/parseMod.ts index d622c0bd..eea46585 100644 --- a/modules/tool/parseMod.ts +++ b/modules/tool/parseMod.ts @@ -8,10 +8,12 @@ export const getIconPath = (name: string) => `${PublicBucketBaseURL}${UploadTool export const parseMod = async ({ rootMod, - filename + filename, + temp = false }: { rootMod: ToolSetType | ToolType; filename: string; + temp?: boolean; }) => { const tools: ToolType[] = []; const checkRootModToolSet = (rootMod: ToolType | ToolSetType): rootMod is ToolSetType => { @@ -20,14 +22,15 @@ export const parseMod = async ({ if (checkRootModToolSet(rootMod)) { const toolsetId = rootMod.toolId; - const parentIcon = rootMod.icon || getIconPath(`${toolsetId}/logo`); + const parentIcon = rootMod.icon || getIconPath(`${temp ? 'temp/' : ''}${toolsetId}/logo`); const children = rootMod.children; for (const child of children) { const childToolId = child.toolId; - const childIcon = child.icon || rootMod.icon || getIconPath(`${childToolId}/logo`); + const childIcon = + child.icon || rootMod.icon || getIconPath(`${temp ? 'temp/' : ''}${childToolId}/logo`); // Generate version for child tool const childVersion = generateToolVersion(child.versionList); @@ -59,7 +62,7 @@ export const parseMod = async ({ // is not toolset const toolId = rootMod.toolId; - const icon = rootMod.icon || getIconPath(`${toolId}/logo`); + const icon = rootMod.icon || getIconPath(`${temp ? 'temp/' : ''}${toolId}/logo`); tools.push({ ...rootMod, diff --git a/modules/tool/utils.ts b/modules/tool/utils.ts index 07d36d26..49d29edd 100644 --- a/modules/tool/utils.ts +++ b/modules/tool/utils.ts @@ -74,7 +74,8 @@ export const parsePkg = async (filepath: string, temp: boolean = true) => { const tools = await parseMod({ rootMod: mod, - filename: join(tempDir, 'index.js') + filename: join(tempDir, 'index.js'), + temp }); await Promise.all([rm(tempDir, { recursive: true }), rm(filepath)]); @@ -91,7 +92,7 @@ export const parseUploadedTool = async (objectName: string) => { }); if (!filepath) return Promise.reject('Upload Tool Error: File not found'); - const tools = await parsePkg(filepath); + const tools = await parsePkg(filepath, true); // 4. remove the uploaded pkg file await privateS3Server.removeFile(objectName); return tools;