mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-29 14:56:36 +03:00
Add process url function.
This commit is contained in:
parent
d86d96b59d
commit
c6e7f18caf
95
examples/docs/functions/process-url/package-lock.json
generated
Normal file
95
examples/docs/functions/process-url/package-lock.json
generated
Normal file
@ -0,0 +1,95 @@
|
||||
{
|
||||
"name": "process-url",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cloudinary": "^1.25.1"
|
||||
}
|
||||
},
|
||||
"node_modules/cloudinary": {
|
||||
"version": "1.25.1",
|
||||
"resolved": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.25.1.tgz",
|
||||
"integrity": "sha512-8iyMyOrRhRudJabdNc34GU/Vnr/ltDRq8gmkwQ4NpuJ1lD5Qw88DJGBNeODZnGSNXIPTLln708gsADVKe0AQMw==",
|
||||
"dependencies": {
|
||||
"cloudinary-core": "^2.10.2",
|
||||
"core-js": "3.6.5",
|
||||
"lodash": "^4.17.11",
|
||||
"q": "^1.5.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/cloudinary-core": {
|
||||
"version": "2.11.4",
|
||||
"resolved": "https://registry.npmjs.org/cloudinary-core/-/cloudinary-core-2.11.4.tgz",
|
||||
"integrity": "sha512-F1BZczD6f5mB73D0c8gl/iuacVQQO+UhckNZxeeS9ZIVeIHbsfqwWiAZMQmIvEb7Wti/9MLU0xVwaWOak2THHA==",
|
||||
"peerDependencies": {
|
||||
"lodash": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/core-js": {
|
||||
"version": "3.6.5",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.5.tgz",
|
||||
"integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==",
|
||||
"hasInstallScript": true,
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/core-js"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
},
|
||||
"node_modules/q": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
|
||||
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=",
|
||||
"engines": {
|
||||
"node": ">=0.6.0",
|
||||
"teleport": ">=0.2.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"cloudinary": {
|
||||
"version": "1.25.1",
|
||||
"resolved": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.25.1.tgz",
|
||||
"integrity": "sha512-8iyMyOrRhRudJabdNc34GU/Vnr/ltDRq8gmkwQ4NpuJ1lD5Qw88DJGBNeODZnGSNXIPTLln708gsADVKe0AQMw==",
|
||||
"requires": {
|
||||
"cloudinary-core": "^2.10.2",
|
||||
"core-js": "3.6.5",
|
||||
"lodash": "^4.17.11",
|
||||
"q": "^1.5.1"
|
||||
}
|
||||
},
|
||||
"cloudinary-core": {
|
||||
"version": "2.11.4",
|
||||
"resolved": "https://registry.npmjs.org/cloudinary-core/-/cloudinary-core-2.11.4.tgz",
|
||||
"integrity": "sha512-F1BZczD6f5mB73D0c8gl/iuacVQQO+UhckNZxeeS9ZIVeIHbsfqwWiAZMQmIvEb7Wti/9MLU0xVwaWOak2THHA==",
|
||||
"requires": {}
|
||||
},
|
||||
"core-js": {
|
||||
"version": "3.6.5",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.5.tgz",
|
||||
"integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA=="
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
},
|
||||
"q": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
|
||||
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc="
|
||||
}
|
||||
}
|
||||
}
|
15
examples/docs/functions/process-url/package.json
Normal file
15
examples/docs/functions/process-url/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "process-url",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cloudinary": "^1.25.1"
|
||||
}
|
||||
}
|
34
examples/docs/functions/process-url/process-url.js
Normal file
34
examples/docs/functions/process-url/process-url.js
Normal file
@ -0,0 +1,34 @@
|
||||
const cloudinary = require("cloudinary").v2;
|
||||
cloudinary.config({
|
||||
cloud_name: "dillonkearns",
|
||||
api_key: process.env.CLOUDINARY_KEY,
|
||||
api_secret: process.env.CLOUDINARY_SECRET,
|
||||
});
|
||||
|
||||
exports.handler = async function (event, ctx) {
|
||||
const pathToScreenshot = event.path.replace(/^.*process-url\//, "");
|
||||
|
||||
try {
|
||||
const imageUrl = cloudinary.url(
|
||||
`https://res.cloudinary.com/dillonkearns/image/upload/v1621026065/elm-pages/1x1-ff00007f_rd0kpy.png`,
|
||||
{
|
||||
// resouce_type: "raw"
|
||||
sign_url: true,
|
||||
// secure: true,
|
||||
custom_pre_function: {
|
||||
function_type: "remote",
|
||||
source: `${process.env.URL}/.netlify/functions/screenshot/${pathToScreenshot}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
return {
|
||||
statusCode: 302,
|
||||
headers: {
|
||||
Location: imageUrl,
|
||||
},
|
||||
body: "",
|
||||
};
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user