-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (25 loc) · 788 Bytes
/
index.js
File metadata and controls
27 lines (25 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
/**
*
* @param {Request} request
* @returns {Promise<Response>}
*/
async function handleRequest(request) {
const pathname = request.url.replace('https://', '').split('/');
return new Response(JSON.stringify({
"name": "NFT Meetup #"+pathname[pathname.length - 1],
"description": "1,000 unique collectible images",
"external_url": "https://github.com/NFT-Meetup-Example",
"image": "https://github.com/NFT-Meetup-Example/images/raw/main/"+pathname[pathname.length - 1]+".png",
"attributes": []
}
), {
headers: { "Content-Type": "application/json" },
});
}