-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from AP-Atul/feat/multiple-options
Feat/multiple options
- Loading branch information
Showing
7 changed files
with
298 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { Lens } from 'ramda'; | ||
|
||
export interface RouteOptions { | ||
// lenses for properties to update | ||
lenses: any[]; | ||
lenses: Lens<object, string>[]; | ||
// path from which source to extract | ||
pathToSource: any; | ||
// source object can also be array | ||
source: object | any[]; | ||
pathToSource?: Lens<object, Response>; | ||
} | ||
|
||
export interface PluginOptions { | ||
// function to generate signed urls | ||
getSignedUrl(key: string): Promise<string>; | ||
} | ||
|
||
export type Response = object | object[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as R from 'ramda'; | ||
|
||
const generateRandomString = (): string => | ||
(Math.random() + 1).toString(36).substring(7).toString(); | ||
|
||
export const getSignedUrl = async (key: string) => (key ? `SIGNED_${key}` : ''); | ||
|
||
export const getSampleObject = async (): Promise<[any, object, object]> => { | ||
const data = { | ||
type: 'png', | ||
image: generateRandomString(), | ||
}; | ||
return [ | ||
R.lensProp<string, any>('image'), | ||
data, | ||
{ | ||
...data, | ||
image: await getSignedUrl(data.image), | ||
}, | ||
]; | ||
}; | ||
|
||
export const getAnotherObject = async (): Promise<[any, object, object]> => { | ||
const data = { | ||
mime: 'png', | ||
file: generateRandomString(), | ||
}; | ||
return [ | ||
R.lensProp<string, any>('file'), | ||
data, | ||
{ | ||
...data, | ||
file: await getSignedUrl(data.file), | ||
}, | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.