mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
refactor image services
This commit is contained in:
11
src/config/cloudinary/helpers/deleteImage.ts
Normal file
11
src/config/cloudinary/helpers/deleteImage.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { cloudinary } from '..';
|
||||
|
||||
/**
|
||||
* Deletes an image from Cloudinary.
|
||||
*
|
||||
* @param path - The cloudinary path of the image to be deleted.
|
||||
* @returns A promise that resolves when the image is successfully deleted.
|
||||
*/
|
||||
const deleteImage = (path: string) => cloudinary.uploader.destroy(path);
|
||||
|
||||
export default deleteImage;
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME,
|
||||
CLOUDINARY_KEY,
|
||||
CLOUDINARY_SECRET,
|
||||
NODE_ENV,
|
||||
} from '../env';
|
||||
import CloudinaryStorage from './CloudinaryStorage';
|
||||
|
||||
@@ -14,6 +15,9 @@ cloudinary.config({
|
||||
});
|
||||
|
||||
/** Cloudinary storage instance. */
|
||||
const storage = new CloudinaryStorage({ cloudinary, params: { folder: 'biergarten' } });
|
||||
const storage = new CloudinaryStorage({
|
||||
cloudinary,
|
||||
params: { folder: NODE_ENV === 'production' ? 'biergarten' : 'biergarten-dev' },
|
||||
});
|
||||
|
||||
export { cloudinary, storage };
|
||||
|
||||
Reference in New Issue
Block a user