refactor: word
This commit is contained in:
parent
d8cf568206
commit
3820a05704
12 changed files with 56 additions and 56 deletions
|
|
@ -20,7 +20,7 @@ import esClient from "../elasticsearch";
|
||||||
import { copyCond, listFolder, listItem, replaceIllegalChars } from "../utils/minio";
|
import { copyCond, listFolder, listItem, replaceIllegalChars } from "../utils/minio";
|
||||||
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { EhrFile, EhrFolder } from "../interfaces/ehr-fs";
|
import { StorageFile, StorageFolder } from "../interfaces/storage-fs";
|
||||||
|
|
||||||
const DEFAULT_BUCKET = process.env.MINIO_BUCKET;
|
const DEFAULT_BUCKET = process.env.MINIO_BUCKET;
|
||||||
const DEFAULT_INDEX = process.env.ELASTICSEARCH_INDEX;
|
const DEFAULT_INDEX = process.env.ELASTICSEARCH_INDEX;
|
||||||
|
|
@ -38,7 +38,7 @@ export class CabinetController extends Controller {
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการตู้เอกสารได้ กรุณาลองใหม่ในภายหลัง",
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการตู้เอกสารได้ กรุณาลองใหม่ในภายหลัง",
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
public async listCabinet(): Promise<EhrFolder[]> {
|
public async listCabinet(): Promise<StorageFolder[]> {
|
||||||
const list = await listFolder(DEFAULT_BUCKET!).catch((e) =>
|
const list = await listFolder(DEFAULT_BUCKET!).catch((e) =>
|
||||||
console.error(`Error List Folder: ${e}`),
|
console.error(`Error List Folder: ${e}`),
|
||||||
);
|
);
|
||||||
|
|
@ -94,7 +94,7 @@ export class CabinetController extends Controller {
|
||||||
return await minioClient.removeObject(DEFAULT_BUCKET!, current.name);
|
return await minioClient.removeObject(DEFAULT_BUCKET!, current.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const search = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
const search = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname: current.name } },
|
query: { match: { pathname: current.name } },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import esClient from "../elasticsearch";
|
||||||
import { copyCond, listFolder, listItem, replaceIllegalChars } from "../utils/minio";
|
import { copyCond, listFolder, listItem, replaceIllegalChars } from "../utils/minio";
|
||||||
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { EhrFile, EhrFolder } from "../interfaces/ehr-fs";
|
import { StorageFile, StorageFolder } from "../interfaces/storage-fs";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
|
|
||||||
const DEFAULT_BUCKET = process.env.MINIO_BUCKET;
|
const DEFAULT_BUCKET = process.env.MINIO_BUCKET;
|
||||||
|
|
@ -39,7 +39,7 @@ export class DrawerController extends Controller {
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการลิ้นชักได้ กรุณาลองใหม่ในภายหลัง",
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการลิ้นชักได้ กรุณาลองใหม่ในภายหลัง",
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
public async listDrawer(@Path() cabinetName: string): Promise<EhrFolder[]> {
|
public async listDrawer(@Path() cabinetName: string): Promise<StorageFolder[]> {
|
||||||
const list = await listFolder(DEFAULT_BUCKET!, `${cabinetName}/`).catch((e) =>
|
const list = await listFolder(DEFAULT_BUCKET!, `${cabinetName}/`).catch((e) =>
|
||||||
console.error(`Error List Folder: ${e}`),
|
console.error(`Error List Folder: ${e}`),
|
||||||
);
|
);
|
||||||
|
|
@ -113,7 +113,7 @@ export class DrawerController extends Controller {
|
||||||
return await minioClient.removeObject(DEFAULT_BUCKET!, current.name);
|
return await minioClient.removeObject(DEFAULT_BUCKET!, current.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const search = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
const search = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname: current.name } },
|
query: { match: { pathname: current.name } },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import esClient from "../elasticsearch";
|
||||||
import minioClient from "../minio";
|
import minioClient from "../minio";
|
||||||
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { EhrFile } from "../interfaces/ehr-fs";
|
import { StorageFile } from "../interfaces/storage-fs";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
|
|
||||||
import { copyCond, pathExist } from "../utils/minio";
|
import { copyCond, pathExist } from "../utils/minio";
|
||||||
|
|
@ -39,8 +39,8 @@ export class FileController extends Controller {
|
||||||
@Path() cabinetName: string,
|
@Path() cabinetName: string,
|
||||||
@Path() drawerName: string,
|
@Path() drawerName: string,
|
||||||
@Path() folderName: string,
|
@Path() folderName: string,
|
||||||
): Promise<EhrFile[]> {
|
): Promise<StorageFile[]> {
|
||||||
const search = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
const search = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: {
|
query: {
|
||||||
prefix: {
|
prefix: {
|
||||||
|
|
@ -54,10 +54,10 @@ export class FileController extends Controller {
|
||||||
.map((v) => {
|
.map((v) => {
|
||||||
if (v._source) {
|
if (v._source) {
|
||||||
const { attachment, ...rest } = v._source;
|
const { attachment, ...rest } = v._source;
|
||||||
return rest satisfies EhrFile;
|
return rest satisfies StorageFile;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter((v: EhrFile | undefined): v is EhrFile => !!v);
|
.filter((v: StorageFile | undefined): v is StorageFile => !!v);
|
||||||
|
|
||||||
return records;
|
return records;
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +94,7 @@ export class FileController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await esClient
|
const result = await esClient
|
||||||
.search<EhrFile & { attachment?: Record<string, unknown> }>({
|
.search<StorageFile & { attachment?: Record<string, unknown> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname } },
|
query: { match: { pathname } },
|
||||||
})
|
})
|
||||||
|
|
@ -112,7 +112,7 @@ export class FileController extends Controller {
|
||||||
|
|
||||||
const rec = result ? result.hits.hits[0]._source : false;
|
const rec = result ? result.hits.hits[0]._source : false;
|
||||||
|
|
||||||
const metadata: Partial<EhrFile> = {
|
const metadata: Partial<StorageFile> = {
|
||||||
pathname,
|
pathname,
|
||||||
fileName: body.file,
|
fileName: body.file,
|
||||||
fileSize: 0,
|
fileSize: 0,
|
||||||
|
|
@ -185,7 +185,7 @@ export class FileController extends Controller {
|
||||||
|
|
||||||
if (copy) {
|
if (copy) {
|
||||||
const search = await esClient
|
const search = await esClient
|
||||||
.search<EhrFile & { attachment?: Record<string, unknown> }>({
|
.search<StorageFile & { attachment?: Record<string, unknown> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname } },
|
query: { match: { pathname } },
|
||||||
})
|
})
|
||||||
|
|
@ -210,7 +210,7 @@ export class FileController extends Controller {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const search = await esClient
|
const search = await esClient
|
||||||
.search<EhrFile & { attachment?: Record<string, unknown> }>({
|
.search<StorageFile & { attachment?: Record<string, unknown> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname } },
|
query: { match: { pathname } },
|
||||||
})
|
})
|
||||||
|
|
@ -269,7 +269,7 @@ export class FileController extends Controller {
|
||||||
@Path() folderName: string,
|
@Path() folderName: string,
|
||||||
@Path() fileName: string,
|
@Path() fileName: string,
|
||||||
) {
|
) {
|
||||||
const search = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
const search = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: {
|
query: {
|
||||||
match: { pathname: `${cabinetName}/${drawerName}/${folderName}/${fileName}` },
|
match: { pathname: `${cabinetName}/${drawerName}/${folderName}/${fileName}` },
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import esClient from "../elasticsearch";
|
||||||
import { copyCond, listFolder, listItem, replaceIllegalChars } from "../utils/minio";
|
import { copyCond, listFolder, listItem, replaceIllegalChars } from "../utils/minio";
|
||||||
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { EhrFile, EhrFolder } from "../interfaces/ehr-fs";
|
import { StorageFile, StorageFolder } from "../interfaces/storage-fs";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
|
|
||||||
const DEFAULT_BUCKET = process.env.MINIO_BUCKET;
|
const DEFAULT_BUCKET = process.env.MINIO_BUCKET;
|
||||||
|
|
@ -42,7 +42,7 @@ export class FolderController extends Controller {
|
||||||
public async listFolder(
|
public async listFolder(
|
||||||
@Path() cabinetName: string,
|
@Path() cabinetName: string,
|
||||||
@Path() drawerName: string,
|
@Path() drawerName: string,
|
||||||
): Promise<EhrFolder[]> {
|
): Promise<StorageFolder[]> {
|
||||||
const list = await listFolder(DEFAULT_BUCKET!, `${cabinetName}/${drawerName}`).catch((e) =>
|
const list = await listFolder(DEFAULT_BUCKET!, `${cabinetName}/${drawerName}`).catch((e) =>
|
||||||
console.error(`Error List Folder: ${e}`),
|
console.error(`Error List Folder: ${e}`),
|
||||||
);
|
);
|
||||||
|
|
@ -117,7 +117,7 @@ export class FolderController extends Controller {
|
||||||
return await minioClient.removeObject(DEFAULT_BUCKET!, current.name);
|
return await minioClient.removeObject(DEFAULT_BUCKET!, current.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const search = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
const search = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname: current.name } },
|
query: { match: { pathname: current.name } },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { Body, Controller, Post, Route, Security, SuccessResponse, Tags } from "
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import esClient from "../elasticsearch";
|
import esClient from "../elasticsearch";
|
||||||
import { Search } from "../interfaces/search";
|
import { Search } from "../interfaces/search";
|
||||||
import { EhrFile } from "../interfaces/ehr-fs";
|
import { StorageFile } from "../interfaces/storage-fs";
|
||||||
|
|
||||||
const DEFAULT_INDEX = process.env.ELASTICSEARCH_INDEX;
|
const DEFAULT_INDEX = process.env.ELASTICSEARCH_INDEX;
|
||||||
|
|
||||||
|
|
@ -14,8 +14,8 @@ export class SearchController extends Controller {
|
||||||
@Tags("ค้นหา")
|
@Tags("ค้นหา")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
public async searchFile(@Body() search: Search): Promise<EhrFile[]> {
|
public async searchFile(@Body() search: Search): Promise<StorageFile[]> {
|
||||||
const result = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
const result = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
|
||||||
index: DEFAULT_INDEX,
|
index: DEFAULT_INDEX,
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import esClient from "../elasticsearch";
|
||||||
import { copyCond, listFolder, listItem, replaceIllegalChars } from "../utils/minio";
|
import { copyCond, listFolder, listItem, replaceIllegalChars } from "../utils/minio";
|
||||||
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { EhrFile, EhrFolder } from "../interfaces/ehr-fs";
|
import { StorageFile, StorageFolder } from "../interfaces/storage-fs";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
|
|
||||||
const DEFAULT_BUCKET = process.env.MINIO_BUCKET;
|
const DEFAULT_BUCKET = process.env.MINIO_BUCKET;
|
||||||
|
|
@ -43,7 +43,7 @@ export class SubFolderController extends Controller {
|
||||||
@Path() cabinetName: string,
|
@Path() cabinetName: string,
|
||||||
@Path() drawerName: string,
|
@Path() drawerName: string,
|
||||||
@Path() folderName: string,
|
@Path() folderName: string,
|
||||||
): Promise<EhrFolder[]> {
|
): Promise<StorageFolder[]> {
|
||||||
const list = await listFolder(
|
const list = await listFolder(
|
||||||
DEFAULT_BUCKET!,
|
DEFAULT_BUCKET!,
|
||||||
`${cabinetName}/${drawerName}/${folderName}`,
|
`${cabinetName}/${drawerName}/${folderName}`,
|
||||||
|
|
@ -121,7 +121,7 @@ export class SubFolderController extends Controller {
|
||||||
return await minioClient.removeObject(DEFAULT_BUCKET!, current.name);
|
return await minioClient.removeObject(DEFAULT_BUCKET!, current.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const search = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
const search = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname: current.name } },
|
query: { match: { pathname: current.name } },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import esClient from "../elasticsearch";
|
||||||
import minioClient from "../minio";
|
import minioClient from "../minio";
|
||||||
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { EhrFile } from "../interfaces/ehr-fs";
|
import { StorageFile } from "../interfaces/storage-fs";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
|
|
||||||
import { copyCond, pathExist } from "../utils/minio";
|
import { copyCond, pathExist } from "../utils/minio";
|
||||||
|
|
@ -42,8 +42,8 @@ export class SubFolderFileController extends Controller {
|
||||||
@Path() drawerName: string,
|
@Path() drawerName: string,
|
||||||
@Path() folderName: string,
|
@Path() folderName: string,
|
||||||
@Path() subFolderName: string,
|
@Path() subFolderName: string,
|
||||||
): Promise<EhrFile[]> {
|
): Promise<StorageFile[]> {
|
||||||
const search = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
const search = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: {
|
query: {
|
||||||
prefix: {
|
prefix: {
|
||||||
|
|
@ -57,10 +57,10 @@ export class SubFolderFileController extends Controller {
|
||||||
.map((v) => {
|
.map((v) => {
|
||||||
if (v._source) {
|
if (v._source) {
|
||||||
const { attachment, ...rest } = v._source;
|
const { attachment, ...rest } = v._source;
|
||||||
return rest satisfies EhrFile;
|
return rest satisfies StorageFile;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter((v: EhrFile | undefined): v is EhrFile => !!v);
|
.filter((v: StorageFile | undefined): v is StorageFile => !!v);
|
||||||
|
|
||||||
return records;
|
return records;
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +98,7 @@ export class SubFolderFileController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await esClient
|
const result = await esClient
|
||||||
.search<EhrFile & { attachment?: Record<string, unknown> }>({
|
.search<StorageFile & { attachment?: Record<string, unknown> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname } },
|
query: { match: { pathname } },
|
||||||
})
|
})
|
||||||
|
|
@ -116,7 +116,7 @@ export class SubFolderFileController extends Controller {
|
||||||
|
|
||||||
const rec = result ? result.hits.hits[0]._source : false;
|
const rec = result ? result.hits.hits[0]._source : false;
|
||||||
|
|
||||||
const metadata: Partial<EhrFile> = {
|
const metadata: Partial<StorageFile> = {
|
||||||
pathname,
|
pathname,
|
||||||
fileName: body.file,
|
fileName: body.file,
|
||||||
fileSize: 0,
|
fileSize: 0,
|
||||||
|
|
@ -190,7 +190,7 @@ export class SubFolderFileController extends Controller {
|
||||||
|
|
||||||
if (copy) {
|
if (copy) {
|
||||||
const search = await esClient
|
const search = await esClient
|
||||||
.search<EhrFile & { attachment?: Record<string, unknown> }>({
|
.search<StorageFile & { attachment?: Record<string, unknown> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname } },
|
query: { match: { pathname } },
|
||||||
})
|
})
|
||||||
|
|
@ -215,7 +215,7 @@ export class SubFolderFileController extends Controller {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const search = await esClient
|
const search = await esClient
|
||||||
.search<EhrFile & { attachment?: Record<string, unknown> }>({
|
.search<StorageFile & { attachment?: Record<string, unknown> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname } },
|
query: { match: { pathname } },
|
||||||
})
|
})
|
||||||
|
|
@ -276,7 +276,7 @@ export class SubFolderFileController extends Controller {
|
||||||
@Path() subFolderName: string,
|
@Path() subFolderName: string,
|
||||||
@Path() fileName: string,
|
@Path() fileName: string,
|
||||||
) {
|
) {
|
||||||
const search = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
const search = await esClient.search<StorageFile & { attachment: Record<string, string> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: {
|
query: {
|
||||||
match: {
|
match: {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
export interface EhrFolder {
|
export interface StorageFolder {
|
||||||
/**
|
/**
|
||||||
* @prop Full path to this folder. It is used as key as there are no files or directories at the same location.
|
* @prop Full path to this folder. It is used as key as there are no files or directories at the same location.
|
||||||
*/
|
*/
|
||||||
|
|
@ -12,7 +12,7 @@ export interface EhrFolder {
|
||||||
createdBy: string | Date;
|
createdBy: string | Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EhrFile {
|
export interface StorageFile {
|
||||||
/**
|
/**
|
||||||
* @prop Full path to this folder. It is used as key as there are no files or directories at the same location.
|
* @prop Full path to this folder. It is used as key as there are no files or directories at the same location.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { EhrFile } from "../interfaces/ehr-fs";
|
import { StorageFile } from "../interfaces/storage-fs";
|
||||||
import esClient from "../elasticsearch";
|
import esClient from "../elasticsearch";
|
||||||
import minioClient from "../minio";
|
import minioClient from "../minio";
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ export async function handler(key: string, event: string): Promise<boolean> {
|
||||||
// Get info and delete it from ElasticSearch to re-index
|
// Get info and delete it from ElasticSearch to re-index
|
||||||
async function popInfo(pathname: string) {
|
async function popInfo(pathname: string) {
|
||||||
const result = await esClient
|
const result = await esClient
|
||||||
.search<EhrFile & { attachment?: Record<string, unknown> }>({
|
.search<StorageFile & { attachment?: Record<string, unknown> }>({
|
||||||
index: DEFAULT_INDEX!,
|
index: DEFAULT_INDEX!,
|
||||||
query: { match: { pathname } },
|
query: { match: { pathname } },
|
||||||
})
|
})
|
||||||
|
|
@ -111,7 +111,7 @@ async function handleNotFoundRecord(
|
||||||
createdBy: "n/a",
|
createdBy: "n/a",
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
updatedBy: "n/a",
|
updatedBy: "n/a",
|
||||||
} satisfies Partial<EhrFile>;
|
} satisfies Partial<StorageFile>;
|
||||||
|
|
||||||
const result = await esClient
|
const result = await esClient
|
||||||
.index({
|
.index({
|
||||||
|
|
@ -127,7 +127,7 @@ async function handleNotFoundRecord(
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleFoundRecord(
|
async function handleFoundRecord(
|
||||||
metadata: EhrFile,
|
metadata: StorageFile,
|
||||||
buffer: Buffer,
|
buffer: Buffer,
|
||||||
stat: { size: number; type: string },
|
stat: { size: number; type: string },
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import type { RequestHandler, Router } from 'express';
|
||||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||||
|
|
||||||
const models: TsoaRoute.Models = {
|
const models: TsoaRoute.Models = {
|
||||||
"EhrFolder": {
|
"StorageFolder": {
|
||||||
"dataType": "refObject",
|
"dataType": "refObject",
|
||||||
"properties": {
|
"properties": {
|
||||||
"pathname": {"dataType":"string","required":true},
|
"pathname": {"dataType":"string","required":true},
|
||||||
|
|
@ -35,7 +35,7 @@ const models: TsoaRoute.Models = {
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
},
|
},
|
||||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||||
"EhrFile": {
|
"StorageFile": {
|
||||||
"dataType": "refObject",
|
"dataType": "refObject",
|
||||||
"properties": {
|
"properties": {
|
||||||
"pathname": {"dataType":"string","required":true},
|
"pathname": {"dataType":"string","required":true},
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
"requestBodies": {},
|
"requestBodies": {},
|
||||||
"responses": {},
|
"responses": {},
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"EhrFolder": {
|
"StorageFolder": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"pathname": {
|
"pathname": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"EhrFile": {
|
"StorageFile": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"pathname": {
|
"pathname": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|
@ -202,7 +202,7 @@
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/EhrFolder"
|
"$ref": "#/components/schemas/StorageFolder"
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
}
|
}
|
||||||
|
|
@ -356,7 +356,7 @@
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/EhrFolder"
|
"$ref": "#/components/schemas/StorageFolder"
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
}
|
}
|
||||||
|
|
@ -544,7 +544,7 @@
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/EhrFile"
|
"$ref": "#/components/schemas/StorageFile"
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
}
|
}
|
||||||
|
|
@ -1042,7 +1042,7 @@
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/EhrFolder"
|
"$ref": "#/components/schemas/StorageFolder"
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
}
|
}
|
||||||
|
|
@ -1262,7 +1262,7 @@
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/EhrFile"
|
"$ref": "#/components/schemas/StorageFile"
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
}
|
}
|
||||||
|
|
@ -1301,7 +1301,7 @@
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/EhrFolder"
|
"$ref": "#/components/schemas/StorageFolder"
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
}
|
}
|
||||||
|
|
@ -1553,7 +1553,7 @@
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/components/schemas/EhrFile"
|
"$ref": "#/components/schemas/StorageFile"
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { EhrFolder } from "../interfaces/ehr-fs";
|
import { StorageFolder } from "../interfaces/storage-fs";
|
||||||
import * as Minio from "minio";
|
import * as Minio from "minio";
|
||||||
import minioClient from "../minio";
|
import minioClient from "../minio";
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ export async function pathExist(path: string): Promise<boolean> {
|
||||||
* @param path - path to list
|
* @param path - path to list
|
||||||
* @return list of folder with metadata
|
* @return list of folder with metadata
|
||||||
*/
|
*/
|
||||||
export async function listFolder(bucket: string, path?: string): Promise<EhrFolder[]> {
|
export async function listFolder(bucket: string, path?: string): Promise<StorageFolder[]> {
|
||||||
if (path) path = `${path.replace(/^\/|\/$/g, "")}/`;
|
if (path) path = `${path.replace(/^\/|\/$/g, "")}/`;
|
||||||
|
|
||||||
const list = await new Promise<{ pathname: string; name: string }[]>((resolve, reject) => {
|
const list = await new Promise<{ pathname: string; name: string }[]>((resolve, reject) => {
|
||||||
|
|
@ -63,11 +63,11 @@ export async function listFolder(bucket: string, path?: string): Promise<EhrFold
|
||||||
...v,
|
...v,
|
||||||
createdAt: createdat ?? "n/a",
|
createdAt: createdat ?? "n/a",
|
||||||
createdBy: createdby ?? "n/a",
|
createdBy: createdby ?? "n/a",
|
||||||
} satisfies EhrFolder;
|
} satisfies StorageFolder;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return folder.filter((v: (typeof folder)[number]): v is EhrFolder => !!v);
|
return folder.filter((v: (typeof folder)[number]): v is StorageFolder => !!v);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listItem(
|
export async function listItem(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue