Created
November 2, 2020 16:53
-
-
Save kitze/aeae3cd1a8d70710ce73e6e407467f69 to your computer and use it in GitHub Desktop.
cloudinary blitz
This file contains hidden or 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
import { cloud } from 'app/config/cloudinary'; | |
import { GetCloudinarySignatureSchema } from 'app/data/images/schema'; | |
import { protect } from 'app/utils/auth-utils'; | |
import { Role } from 'app/utils/enums'; | |
import { getEnv } from 'app/utils/get-env'; | |
export default protect( | |
{ schema: GetCloudinarySignatureSchema, role: Role.User }, | |
async function getCloudinarySignature({ publicId, folder }) { | |
const timestamp = Math.round(new Date().getTime() / 1000); | |
const api_secret: string = getEnv('CLOUDINARY_SECRET') as string; | |
const params = { | |
public_id: publicId, | |
timestamp, | |
folder, | |
}; | |
return cloud.utils.sign_request(params, { api_secret }); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment