https://github.com/arthurdenner/parse-cloudinary-url
Parses a Cloudinary env variable string
https://github.com/arthurdenner/parse-cloudinary-url
Last synced: 3 months ago
JSON representation
Parses a Cloudinary env variable string
- Host: GitHub
- URL: https://github.com/arthurdenner/parse-cloudinary-url
- Owner: arthurdenner
- License: mit
- Created: 2022-02-17T14:33:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-28T13:50:41.000Z (about 3 years ago)
- Last Synced: 2025-01-23T19:53:07.824Z (5 months ago)
- Language: TypeScript
- Size: 173 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# parse-cloudinary-url
A module to transform a Cloudinary string used as an environment variable to an object.
## Usage
```js
import { parse } from 'parse-cloudinary-url';
const CLOUDINARY_URL = 'cloudinary://apiKey:apiSecret@cloudName?uploadFolder=customFolder';
const uploadConfig = parse(CLOUDINARY_URL);/*
{
apiKey: "apiKey",
apiSecret: "apiSecret",
cloudName: "cloudName",
options: {
uploadFolder: "customFolder",
},
}
*/
```### Strapi
I created this module from a Strapi project because I wanted to use only one variable instead of many.
If you're in the same scenario, this module can be used as below:
```js
import { parse } from 'parse-cloudinary-url';module.exports = ({ env }) => {
const uploadConfig = parse(env('CLOUDINARY_URL'));return {
upload: {
provider: 'cloudinary',
providerOptions: {
api_key: uploadConfig.apiKey,
api_secret: uploadConfig.apiSecret,
cloud_name: uploadConfig.cloudName,
},
actionOptions: {
upload: {
folder: uploadConfig.options.uploadFolder,
},
},
},
};
};
```