feat: additional field

This commit is contained in:
Methapon2001 2023-12-26 14:52:02 +07:00
parent 2da9f91e4e
commit ae2e0edfd2
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
5 changed files with 110 additions and 1 deletions

View file

@ -3,6 +3,23 @@ import esClient from "../elasticsearch";
import minioClient from "../minio";
import * as io from "../lib/websocket";
// const MINIO_ERROR_MESSAGE = "เกิดข้อผิดพลาดกับระบบจัดการไฟล์";
// async function checkPathExist(bucket: string, path: string[]) {
// if (path.filter(Boolean).length === 0) return true; // root does not contain any mark
// return await checkFileExist(bucket, `${path.filter(Boolean).join("/")}/.keep`);
// }
//
// async function checkFileExist(bucket: string, pathname: string) {
// return Boolean(
// await minioClient.statObject(bucket, stripLeadingSlash(pathname)).catch((e) => {
// if (e.code === "NotFound") return false;
// console.error(`Storage Error: ${e}`);
// throw new Error(MINIO_ERROR_MESSAGE);
// }),
// );
// }
const DEFAULT_INDEX = process.env.ELASTICSEARCH_INDEX;
if (!DEFAULT_INDEX) throw Error("Default ElasticSearch index must be specified.");
@ -122,15 +139,17 @@ async function handleNotFoundRecord(
fileType: stat.type,
title: "",
description: "",
author: "",
category: [],
keyword: [],
metadata: {},
upload: true,
hidden: false,
createdAt: new Date().toISOString(),
createdBy: "n/a",
updatedAt: new Date().toISOString(),
updatedBy: "n/a",
} satisfies Partial<StorageFile>;
} satisfies StorageFile;
const result = await esClient
.index({