Skip to content

Commit

Permalink
fix: move bucket and file api to package folder
Browse files Browse the repository at this point in the history
docs look better when we do this and add the packages to the entrypoint to the typedoc command
  • Loading branch information
inian committed Aug 11, 2022
1 parent cb1804b commit 15aaea2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"test:suite": "jest --runInBand",
"test:infra": "cd infra && docker-compose down && docker-compose up -d && sleep 10",
"test:clean": "cd infra && docker-compose down --remove-orphans",
"docs": "typedoc --theme default --entryPoints src/index.ts",
"docs:json": "typedoc --json docs/spec.json --excludeExternals --entryPoints src/index.ts"
"docs": "typedoc --entryPoints src/index.ts --entryPoints src/packages/* --excludePrivate",
"docs:json": "typedoc --json docs/spec.json --entryPoints src/index.ts --entryPoints src/packages/* --excludePrivate --excludeExternals"
},
"dependencies": {
"cross-fetch": "^3.1.5"
Expand Down
3 changes: 2 additions & 1 deletion src/StorageClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StorageBucketApi, StorageFileApi } from './lib'
import StorageFileApi from './packages/StorageFileApi'
import StorageBucketApi from './packages/StorageBucketApi'
import { Fetch } from './lib/fetch'

export class StorageClient extends StorageBucketApi {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './StorageBucketApi'
export * from './StorageFileApi'
export * from '../packages/StorageBucketApi'
export * from '../packages/StorageFileApi'
export * from './types'
export * from './constants'
12 changes: 6 additions & 6 deletions src/lib/StorageBucketApi.ts → src/packages/StorageBucketApi.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DEFAULT_HEADERS } from './constants'
import { isStorageError, StorageError } from './errors'
import { Fetch, get, post, put, remove } from './fetch'
import { resolveFetch } from './helpers'
import { Bucket } from './types'
import { DEFAULT_HEADERS } from '../lib/constants'
import { isStorageError, StorageError } from '../lib/errors'
import { Fetch, get, post, put, remove } from '../lib/fetch'
import { resolveFetch } from '../lib/helpers'
import { Bucket } from '../lib/types'

export class StorageBucketApi {
export default class StorageBucketApi {
protected url: string
protected headers: { [key: string]: string }
protected fetch: Fetch
Expand Down
14 changes: 7 additions & 7 deletions src/lib/StorageFileApi.ts → src/packages/StorageFileApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isStorageError, StorageError } from './errors'
import { Fetch, FetchParameters, get, post, remove } from './fetch'
import { resolveFetch } from './helpers'
import { FileObject, FileOptions, SearchOptions } from './types'
import { isStorageError, StorageError } from '../lib/errors'
import { Fetch, FetchParameters, get, post, remove } from '../lib/fetch'
import { resolveFetch } from '../lib/helpers'
import { FileObject, FileOptions, SearchOptions } from '../lib/types'

const DEFAULT_SEARCH_OPTIONS = {
limit: 100,
Expand All @@ -18,7 +18,7 @@ const DEFAULT_FILE_OPTIONS: FileOptions = {
upsert: false,
}

export class StorageFileApi {
export default class StorageFileApi {
protected url: string
protected headers: { [key: string]: string }
protected bucketId?: string
Expand Down Expand Up @@ -526,11 +526,11 @@ export class StorageFileApi {
}
}

_getFinalPath(path: string) {
private _getFinalPath(path: string) {
return `${this.bucketId}/${path}`
}

_removeEmptyFolders(path: string) {
private _removeEmptyFolders(path: string) {
return path.replace(/^\/|\/$/g, '').replace(/\/+/g, '/')
}
}
2 changes: 1 addition & 1 deletion test/storageApi.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StorageBucketApi } from '../src/lib'
import StorageBucketApi from '../src/packages/StorageBucketApi'

// TODO: need to setup storage-api server for this test
const URL = 'http://localhost:8000/storage/v1'
Expand Down

0 comments on commit 15aaea2

Please sign in to comment.