moved services in proper services

This commit is contained in:
didier amyot committed 2023-06-13 08:25:36 -04:00
1 parent bbd705ee3b
commit d12600348f
7 files changed
+61 -48

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
export { Buffer, StringReader } from "https://deno.land/std@0.191.0/io/mod.ts";
export { readAll, readerFromIterable, readableStreamFromReader, readerFromStreamReader, iterateReader, TextLineStream } from "https://deno.land/std@0.191.0/streams/mod.ts";
export { Application, Context, Router } from 'https://deno.land/x/oak/mod.ts';
+3 -3
View File
@@ -1,6 +1,6 @@
import { Context, Router } from "https://deno.land/x/oak/mod.ts";
import { FileService } from "./fileservice.ts";
import { readerFromStreamReader, readableStreamFromReader, TextLineStream } from "https://deno.land/std@0.191.0/streams/mod.ts";
import { Context, Router } from "./deps.ts";
import { FileService } from "./services/mod.ts";
import { readerFromStreamReader } from "./deps.ts";
import { asyncIterableToArray } from "./utils.ts";
+2 -2
View File
@@ -1,6 +1,6 @@
import { Application, Router } from 'https://deno.land/x/oak/mod.ts';
import { Application, Router } from './deps.ts';
import { buildAPI } from './restapi.ts';
import { DenoKVFileService } from "./fileservice.ts";
import { DenoKVFileService } from "./services/mod.ts";
async function main(){
const app = new Application();
+5 -42
View File
@@ -1,42 +1,10 @@
import { readAll } from "https://deno.land/std@0.191.0/streams/read_all.ts";
import { readerFromIterable, iterateReader } from "https://deno.land/std@0.191.0/streams/mod.ts";
import { Buffer } from "https://deno.land/std@0.191.0/io/buffer.ts";
import { StringReader } from "https://deno.land/std@0.191.0/io/string_reader.ts";
import { readAll, readerFromIterable, iterateReader } from "../deps.ts";
import { Buffer, StringReader } from "../deps.ts";
import {FileService, FileMetaData, BlobService} from './interfaces.ts';
import { readerFromStreamReader, readableStreamFromReader } from "https://deno.land/std@0.191.0/streams/mod.ts";
export interface FileService {
list(): AsyncIterable<FileMetaData>;
createFromFullContent(
path: string,
content: string | Uint8Array,
): Promise<FileMetaData>;
createFromReader(path: string, content: Deno.Reader): Promise<FileMetaData>;
getRawContentByPath(path: string): Promise<Uint8Array | null>;
getContentAsReader(path: string): Promise<Deno.Reader | null>;
getMetaDataByID(id: string): Promise<FileMetaData | null>;
renameById(id: string, newPath: string): Promise<FileMetaData | null>;
renameByPath(
originalPath: string,
newPath: string,
): Promise<FileMetaData | null>;
deleteByPath(path: string): Promise<boolean>;
}
interface SerializedFile {
id: string;
path: string;
@@ -44,17 +12,12 @@ interface SerializedFile {
compression: string;
}
export interface FileMetaData {
path: string;
id: string;
contentSize: number;
}
interface SerializedFilePathIndex {
fileId: string;
}
export class DenoKVBlobService {
export class DenoKVBlobService implements BlobService {
private readonly kv: Deno.Kv;
private readonly blobSize: number;
@@ -172,7 +135,7 @@ export class DenoKVBlobService {
export class DenoKVFileService implements FileService {
private readonly kv: Deno.Kv;
private readonly blobService: DenoKVBlobService;
private readonly blobService: BlobService;
constructor(kv: Deno.Kv) {
this.kv = kv;
+43
View File
@@ -0,0 +1,43 @@
export interface FileMetaData {
path: string;
id: string;
contentSize: number;
}
export interface FileService {
list(): AsyncIterable<FileMetaData>;
createFromFullContent(
path: string,
content: string | Uint8Array,
): Promise<FileMetaData>;
createFromReader(path: string, content: Deno.Reader): Promise<FileMetaData>;
getRawContentByPath(path: string): Promise<Uint8Array | null>;
getContentAsReader(path: string): Promise<Deno.Reader | null>;
getMetaDataByID(id: string): Promise<FileMetaData | null>;
renameById(id: string, newPath: string): Promise<FileMetaData | null>;
renameByPath(
originalPath: string,
newPath: string,
): Promise<FileMetaData | null>;
deleteByPath(path: string): Promise<boolean>;
}
export interface BlobService {
persistBlob(index: string, content: Uint8Array): Promise<number>;
persistReader(index: string, content: Deno.Reader): Promise<number>;
readAllBlob(index: string): Promise<Uint8Array>;
getBlob(index: string): Deno.Reader;
getNumberOfBlobs(index: string): Promise<number>;
streamBlob(index: string): Deno.Reader;
}
+2
View File
@@ -0,0 +1,2 @@
export * from './interfaces.ts';
export {DenoKVBlobService, DenoKVFileService} from './denokv.ts';
+1 -1
View File
@@ -5,7 +5,7 @@ import {
DenoKVFileService,
FileMetaData,
FileService,
} from "../src/fileservice.ts";
} from "../src/services/mod.ts";
import { asyncIterableToArray } from "../src/utils.ts";
import { generateLargeText } from "./utils.ts";
import { StringReader } from "https://deno.land/std@0.191.0/io/mod.ts";