Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit ef2c2aa

Browse files
authored
Merge pull request #318 from kodadot/main
one api key down
2 parents 2b18e4c + 8425475 commit ef2c2aa

File tree

22 files changed

+822
-93
lines changed

22 files changed

+822
-93
lines changed

dashboard/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ yarn-error.log*
2323
.netlify
2424
.vercel
2525
/test
26+
27+
# Local Netlify folder
28+
.netlify

dashboard/functions/pinHash.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashboard/functions/pinJson.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashboard/functions/test.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashboard/functions/unpin.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashboard/netlify.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
[build]
2+
# This will be your default build command.
3+
command = "npm run build"
4+
# This is where Netlify will look for your lambda functions.
5+
functions = "functions"
6+
# This is the directory that you are publishing from.
7+
publish = "dist"
18
[[redirects]]
29
from = "/*"
310
to = "/index.html"

dashboard/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"private": true,
55
"scripts": {
66
"serve": "vue-cli-service serve",
7-
"build": "vue-cli-service build",
7+
"build": "netlify-lambda build src-functions && vue-cli-service build",
88
"lint": "vue-cli-service lint",
99
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'",
10-
"start": "vue-cli-service serve"
10+
"start": "vue-cli-service serve",
11+
"lambda": "netlify-lambda serve src-functions"
1112
},
1213
"dependencies": {
1314
"@fortawesome/fontawesome-svg-core": "^1.2.34",
@@ -33,6 +34,7 @@
3334
"lazysizes": "^5.3.0",
3435
"markdown-it-vue": "^1.1.6",
3536
"mingo": "^4.1.2",
37+
"netlify-lambda": "^2.0.4",
3638
"register-service-worker": "^1.7.1",
3739
"setimmediate": "^1.0.5",
3840
"slugify": "^1.4.6",

dashboard/src-functions/pinHash.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import axios from "axios"
2+
3+
exports.handler = async (event, context) => {
4+
5+
6+
// const location = event.queryStringParameters.location || "home";
7+
const BASE_URL = 'https://api.pinata.cloud/pinning/pinByHash';
8+
const object = event.body;
9+
10+
try {
11+
const { status, data } = await axios.post(BASE_URL, object, {
12+
headers: {
13+
'Content-Type': 'application/json',
14+
pinata_api_key: process.env.PINATA_API_KEY,
15+
pinata_secret_api_key: process.env.PINATA_SECRET_API_KEY
16+
},
17+
});
18+
console.log('[PINATA] Pin HASH', status, data);
19+
20+
return {
21+
statusCode: status,
22+
body: JSON.stringify(data),
23+
};
24+
25+
26+
} catch (e) {
27+
console.log('Error', e.message)
28+
return {
29+
statusCode: 500,
30+
body: e.message,
31+
};
32+
}
33+
34+
};
35+

dashboard/src-functions/pinJson.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import axios from "axios"
2+
3+
exports.handler = async (event, context) => {
4+
5+
6+
// const location = event.queryStringParameters.location || "home";
7+
const BASE_URL = 'https://api.pinata.cloud/pinning/pinJSONToIPFS';
8+
const object = event.body;
9+
10+
try {
11+
const { status, data } = await axios.post(BASE_URL, object, {
12+
headers: {
13+
'Content-Type': 'application/json',
14+
pinata_api_key: process.env.PINATA_API_KEY,
15+
pinata_secret_api_key: process.env.PINATA_SECRET_API_KEY
16+
},
17+
});
18+
console.log('[PINATA] Pin JSON', status, data);
19+
20+
if (status < 400) {
21+
return {
22+
statusCode: status,
23+
body: JSON.stringify(data),
24+
};
25+
}
26+
27+
28+
} catch (e) {
29+
console.log('Error', e.message)
30+
return {
31+
statusCode: 500,
32+
body: e.message,
33+
};
34+
}
35+
36+
return {
37+
statusCode: status,
38+
body: JSON.stringify({}),
39+
};
40+
41+
42+
};
43+

dashboard/src-functions/test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import axios from "axios"
2+
3+
exports.handler = async (event, context) => {
4+
5+
const BASE_URL = `https://api.pinata.cloud/data/testAuthentication`;
6+
const { PINATA_API_KEY, PINATA_SECRET_API_KEY } = process.env;
7+
8+
console.log(PINATA_API_KEY, PINATA_SECRET_API_KEY)
9+
10+
try {
11+
const { status, data } = await axios.get(BASE_URL, {
12+
headers: {
13+
pinata_api_key: PINATA_API_KEY,
14+
pinata_secret_api_key: PINATA_SECRET_API_KEY,
15+
},
16+
});
17+
console.log('[PINATA] TEST', status, data);
18+
19+
return {
20+
statusCode: status,
21+
body: JSON.stringify(data),
22+
};
23+
24+
25+
} catch (e) {
26+
console.log('Error', e.message)
27+
return {
28+
statusCode: 500,
29+
body: e.message,
30+
};
31+
}
32+
33+
};
34+

0 commit comments

Comments
 (0)