Skip to content

Commit

Permalink
feat(app): backend logic
Browse files Browse the repository at this point in the history
- changed folder structure to accommodate BE logic
  • Loading branch information
amjedidiah committed Nov 21, 2024
1 parent edfe2ea commit b0da73a
Showing 72 changed files with 759 additions and 287 deletions.
4 changes: 0 additions & 4 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -19,10 +19,6 @@ const config = {
},
},
],
docs: {
autodocs: true,
defaultName: 'Documentation',
},
core: {
builder: '@storybook/builder-webpack5',
},
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../src/tailwind.css'
import '../src/frontend/tailwind.css'

// https://storybook.js.org/docs/react/writing-stories/parameters#global-parameters
export const parameters = {
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -108,6 +108,7 @@
"@aws-sdk/client-s3": "^3.689.0",
"@aws-sdk/s3-request-presigner": "^3.689.0",
"@aws-sdk/xhr-http-handler": "^3.451.0",
"@azure/identity": "^4.5.0",
"@azure/msal-browser": "^3.5.0",
"@azure/storage-blob": "^12.25.0",
"@emotion/styled": "^11.11.0",
111 changes: 111 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 18 additions & 16 deletions src/UpupUploader.tsx
Original file line number Diff line number Diff line change
@@ -4,15 +4,23 @@ import {
MetaVersion,
OneDriveUploader,
UrlUploader,
} from 'components'
import { UpupMini } from 'components/UpupMini'
} from 'frontend/components'
import { UpupMini } from 'frontend/components/UpupMini'
import {
DropZone,
MethodsSelector,
Preview,
View,
} from 'components/UpupUploader'
import { useAddMore, useDragAndDrop } from 'hooks'
} from 'frontend/components/UpupUploader'
import { useAddMore, useDragAndDrop } from 'frontend/hooks'
import {
BaseConfigs,
GoogleConfigs,
METHODS,
OneDriveConfigs,
UPLOAD_ADAPTER,
UploadAdapter,
} from 'frontend/types'
import { checkFileSize, checkFileType, compressFile, sizeToBytes } from 'lib'
import {
FC,
@@ -25,19 +33,11 @@ import {
useImperativeHandle,
useState,
} from 'react'
import {
BaseConfigs,
GoogleConfigs,
METHODS,
OneDriveConfigs,
UPLOAD_ADAPTER,
UploadAdapter,
} from 'types'

import { AnimatePresence } from 'framer-motion'
import { StorageConfig } from 'frontend/types/StorageSDK'
import { ProviderSDK } from 'lib/storage/provider'
import { StorageConfig } from 'types/StorageSDK'
import useProgress from './hooks/useProgress'
import useProgress from './frontend/hooks/useProgress'

export interface UpupUploaderProps {
storageConfig: StorageConfig
@@ -121,7 +121,9 @@ export const UpupUploader: FC<
return new Promise(async (resolve, reject) => {
try {
// Validate files
filesList.forEach(file => checkFileType(file, accept))
filesList.forEach(file =>
checkFileType(accept, file.type),
)

// Process files (compression if needed)
const processedFiles = toBeCompressed
@@ -275,7 +277,7 @@ export const UpupUploader: FC<
onChange={e => {
const acceptedFiles = Array.from(
e.target.files as FileList,
).filter(file => checkFileType(file, accept))
).filter(file => checkFileType(accept, file.type))

const newFiles = multiple
? isAddingMore
36 changes: 36 additions & 0 deletions src/backend/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { S3ClientConfig } from '@aws-sdk/client-s3'
import { Provider } from 'types/StorageSDK'

export interface FileParams {
name: string
type: string
size: number

accept?: string
maxFileSize?: number
multiple?: boolean
}

interface UrlParams {
fileParams: FileParams
expiresIn?: number
}

export type S3PresignedUrlParams = UrlParams & {
bucketName: string
s3ClientConfig: S3ClientConfig
origin: string
provider: Provider
}

export type AzureSasUrlParams = UrlParams & {
containerName: string
credentials: AzureCredentials
}

export type AzureCredentials = {
tenantId: string
clientId: string
clientSecret: string
storageAccount: string
}
Loading

0 comments on commit b0da73a

Please sign in to comment.