Skip to content

Commit

Permalink
move module types to src
Browse files Browse the repository at this point in the history
  • Loading branch information
itsnotrisky committed Feb 4, 2020
1 parent e763f92 commit f874646
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Use [Signed URLs](https://cloud.google.com/storage/docs/access-control/signed-urls) to upload a file straight to Cloud Storage. It returns `optimisticUrl` to access the file once it is uploaded.

## Usage
```
```js
import signedUpload, { getUrls, upload } from '@pozible/signed-upload'

const {optimisticUrl, signedUrl} = await getUrls(metadata, filePath, config)
Expand All @@ -16,7 +16,7 @@ const {optimisticUrl} = await signedUpload(file, metadata, filePath, config)
## Arguments
### `metadata`
`dimensions` attribute is used together with Cloud Function listening on bucket's changes to further process the image. Omit it when uploading generic files.
```
```js
{
dimensions: {
imageUrl: {
Expand All @@ -35,7 +35,7 @@ const {optimisticUrl} = await signedUpload(file, metadata, filePath, config)

### `filePath`
A function to provide a final path to the file in your bucket with uuid as a parameter to give random value to the file name. No need to add extension as it will be automatically added based on given filename in `metadata`.
```
```js
const filePath = randomId => `/path/to/your/file-with-${randomId}`
const filePath = () => `/path/to/your/original-file-name`
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pozible/signed-upload",
"version": "1.0.1",
"version": "1.0.2",
"description": "Bootstrapped file upload.",
"main": "index.js",
"types": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/getOptimisticPath.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IDictionary, Metadata } from '../module'
import { IDictionary, Metadata } from './module'

const getExtension = fileName => fileName.split('.').pop()

Expand Down
2 changes: 1 addition & 1 deletion src/getOptimisticUrl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IDictionary, Config } from "../module"
import { IDictionary, Config } from "./module"

export default ({baseUrl, bucketName}:Config, optimisticPath:IDictionary<string>) => {
const storageUrl = 'https://storage.googleapis.com'
Expand Down
2 changes: 1 addition & 1 deletion src/getSignedUrl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Storage } from '@google-cloud/storage'
import { Metadata } from '../module'
import { Metadata } from './module'

const storage = new Storage()

Expand Down
2 changes: 1 addition & 1 deletion src/getUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import uuidv1 from 'uuid/v1'
import getOptimisticPath from './getOptimisticPath'
import getOptimisticUrl from './getOptimisticUrl'
import getSignedUrl from './getSignedUrl'
import { Metadata, Config } from '../module'
import { Metadata, Config } from './module'

export default async (metadata:Metadata, filePath, config:Config) => {
const fp = filePath(uuidv1())
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Metadata, Config } from '../module'
import { Metadata, Config } from './module'
import _getUrls from './getUrls'
import _upload from './upload'

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/upload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetch from 'node-fetch'
import { Metadata } from '../module'
import { Metadata } from './module'

export default (file, metadata:Metadata, signedUrl:string) => {
return fetch(signedUrl, {
Expand Down

0 comments on commit f874646

Please sign in to comment.