Skip to content

Instantly share code, notes, and snippets.

@kitze
Created November 2, 2020 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitze/aeae3cd1a8d70710ce73e6e407467f69 to your computer and use it in GitHub Desktop.
Save kitze/aeae3cd1a8d70710ce73e6e407467f69 to your computer and use it in GitHub Desktop.
cloudinary blitz
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