File tree 4 files changed +71
-1
lines changed
4 files changed +71
-1
lines changed Original file line number Diff line number Diff line change 1
1
install :
2
- cd functions/gen-opengraph-image && npm i && npm run build
2
+ cd functions/gen-opengraph-image && npm i && npm run build
3
+ cd functions/process-url && npm i
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " process-url" ,
3
+ "version" : " 1.0.0" ,
4
+ "main" : " index.js" ,
5
+ "author" :
" christopherbiscardi <[email protected] > (@chrisbiscardi)" ,
6
+ "license" : " MIT" ,
7
+ "dependencies" : {
8
+ "cloudinary" : " ^1.20.0"
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ const cloudinary = require ( "cloudinary" ) . v2 ;
2
+ const qs = require ( "querystring" ) ;
3
+ cloudinary . config ( {
4
+ cloud_name : "sector" ,
5
+ api_key : process . env . CLOUDINARY_KEY ,
6
+ api_secret : process . env . CLOUDINARY_SECRET
7
+ } ) ;
8
+
9
+ exports . handler = async function ( event , ctx ) {
10
+ const { queryStringParameters } = event ;
11
+
12
+ try {
13
+ // https://res.cloudinary.com/sector/image/upload/v1583637123/og-images/img-1.png
14
+ const imageUrl = cloudinary . url (
15
+ `${ process . env . CHRIS_IMAGE_VERSION } /og-images/img-1.png` ,
16
+ {
17
+ // resouce_type: "raw"
18
+ sign_url : true ,
19
+ // secure: true,
20
+ custom_pre_function : {
21
+ function_type : "remote" ,
22
+ source : `https://relaxed-payne-d1bfbe.netlify.com/.netlify/functions/gen-opengraph-image?${ qs . stringify (
23
+ queryStringParameters
24
+ ) } `
25
+ }
26
+ }
27
+ ) ;
28
+ return {
29
+ statusCode : 302 ,
30
+ headers : {
31
+ Location : imageUrl
32
+ } ,
33
+ body : ""
34
+ } ;
35
+ } catch ( e ) {
36
+ console . log ( e ) ;
37
+ }
38
+ } ;
Original file line number Diff line number Diff line change
1
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ # yarn lockfile v1
3
+
4
+
5
+ cloudinary@^1.20.0 :
6
+ version "1.20.0"
7
+ resolved "https://registry.yarnpkg.com/cloudinary/-/cloudinary-1.20.0.tgz#88f3964be91cc9808b5c7834bf06e03d22954636"
8
+ integrity sha512-/e76lEr5PS5gefvWUJ2Ou90zuEQCc0agTq8hrx2uxfFhUGlzEQ9mPPcwAeHFY1gj9caq0iHLuvTDvBbLSRhX9w==
9
+ dependencies :
10
+ lodash "^4.17.11"
11
+ q "^1.5.1"
12
+
13
+ lodash@^4.17.11 :
14
+ version "4.17.15"
15
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
16
+ integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
17
+
18
+ q@^1.5.1 :
19
+ version "1.5.1"
20
+ resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
21
+ integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
You can’t perform that action at this time.
0 commit comments