Skip to content

Commit

Permalink
refactor(storage): change storage folder structure (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkopanidis committed Aug 23, 2022
1 parent 37a6fa9 commit dfe5a34
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 49 deletions.
5 changes: 3 additions & 2 deletions modules/storage/src/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import AppConfigSchema, { Config } from './config';
import { AdminRoutes } from './admin';
import { FileHandlers } from './handlers/file';
import { StorageRoutes } from './routes';
import { createStorageProvider, IStorageProvider } from './storage-provider';
import * as models from './models';
import path from 'path';
import { status } from '@grpc/grpc-js';
import { isNil } from 'lodash';
import { getAwsAccountId } from './storage-provider/utils/utils';
import { isEmpty } from 'lodash';
import { runMigrations } from './migrations';
import { FileResponse, GetFileDataResponse } from './protoTypes/storage';
import { IStorageProvider } from './interfaces';
import { createStorageProvider } from './providers';
import { getAwsAccountId } from './utils';

type Callback = (arg1: { code: number; message: string }) => void;

Expand Down
2 changes: 1 addition & 1 deletion modules/storage/src/handlers/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import ConduitGrpcSdk, {
} from '@conduitplatform/grpc-sdk';
import { status } from '@grpc/grpc-js';
import { isNil, isString } from 'lodash';
import { IStorageProvider } from '../storage-provider';
import { _StorageContainer, _StorageFolder, File } from '../models';
import { IStorageProvider } from '../interfaces';

export class FileHandlers {
private readonly database: DatabaseProvider;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { IStorageProvider, StorageConfig } from '../../interfaces';

import OSS from 'ali-oss';

import fs from 'fs';

import { basename } from 'path';

export class AliyunStorage implements IStorageProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
S3Client,
} from '@aws-sdk/client-s3';
import { Readable } from 'stream';
import { streamToBuffer } from '../../utils/utils';
import { streamToBuffer } from '../../utils';
import fs from 'fs';
import { getSignedUrl as awsGetSignedUrl } from '@aws-sdk/s3-request-presigner';
import ConduitGrpcSdk, { ConfigController } from '@conduitplatform/grpc-sdk';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
SASProtocol,
} from '@azure/storage-blob';
import fs from 'fs';
import { streamToBuffer } from '../../utils/utils';
import ConduitGrpcSdk from '@conduitplatform/grpc-sdk';
import { streamToBuffer } from '../../utils';

export class AzureStorage implements IStorageProvider {
_activeContainer: string = '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IStorageProvider, StorageConfig } from '../../interfaces';

import { Storage } from '@google-cloud/storage';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { IStorageProvider, StorageConfig } from './interfaces';
import { GoogleCloudStorage } from './providers/google';
import { LocalStorage } from './providers/local';
import { AzureStorage } from './providers/azure';
import { AWSS3Storage } from './providers/aws';
import { AliyunStorage } from './providers/aliyun';
import { IStorageProvider, StorageConfig } from '../interfaces';
import { GoogleCloudStorage } from './google';
import { LocalStorage } from './local';
import { AzureStorage } from './azure';
import { AWSS3Storage } from './aws';
import { AliyunStorage } from './aliyun';

export function createStorageProvider(
provider: keyof StorageConfig,
Expand All @@ -24,5 +24,3 @@ export function createStorageProvider(
return new LocalStorage(options);
}
}

export * from './interfaces';
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IStorageProvider } from '../../interfaces';
import { StorageConfig } from '../../interfaces';
import { IStorageProvider, StorageConfig } from '../../interfaces';
import {
constants,
chmod,
Expand Down
28 changes: 0 additions & 28 deletions modules/storage/src/storage-provider/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { GetUserCommand, IAMClient } from '@aws-sdk/client-iam';
import { isNil } from 'lodash';
import { ConfigController } from '@conduitplatform/grpc-sdk';
import { StorageConfig } from '../interfaces';

export async function streamToBuffer(readableStream: any): Promise<Buffer> {
Expand Down

0 comments on commit dfe5a34

Please sign in to comment.