eminvergil

eminvergil

import "@johnlindquist/kit"
let envOptions = {
hint: md(
`You need to [sign up](https://rapidapi.com/Veriphone/api/veriphone/) to get cridential key`
),
ignoreBlur: true,
secret: true,
};
let rapid_api_key = await env("RAPID_API_KEY", envOptions);
const options = {
method: "GET",
headers: {
"X-RapidAPI-Key": rapid_api_key,
"X-RapidAPI-Host": "veriphone.p.rapidapi.com",
},
};
let phone_number = await arg("type your phone number")
let verify_response = await fetch(`https://veriphone.p.rapidapi.com/verify?phone=${phone_number}`, options);
let response = await verify_response.json();
let isSuccessfull = response.status_code === 200;
{isSuccessfull && await div(
`<h1 class="p-10 text-4xl text-center">${response.status === "success" ? "verified" : "not verified"}</h1>`
)}
{!isSuccessfull && await div(
`<h1 class="p-10 text-4xl text-center">some error occurred.</h1>`
)}

let envOptions = {
hint: md(
`You need to [create an app](https://developer.spotify.com/dashboard/applications) to client_id and client_secret`
),
ignoreBlur: true,
secret: true,
};
let client_id = await env("SPOTIFY_CLIENT_ID", envOptions);
let client_secret = await env("SPOTIFY_CLIENT_SECRET", envOptions);
var token = await fetch("https://accounts.spotify.com/api/token", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Accept: "application/json",
Authorization:
"Basic " + new Buffer(client_id + ":" + client_secret).toString("base64"),
},
body: "grant_type=client_credentials",
}).then((res) => res.json());
let GetAlbums = async (artist_name) => {
let tokenResponse = await token.json();
let response = await fetch(
`https://api.spotify.com/v1/search?type=album&include_external=audio&q=${artist_name}`,
{
headers: {
Authorization: "Bearer " + tokenResponse.res.access_token,
"Content-type": "application/json",
},
}
);
let data = await response.json();
};
let artist_name = await args("artist name...");
let albums = await GetAlbums(artist_name);
await div(
`
<div className="grid lg:grid-cols-4 md:grid-cols-2 grid-cols-1 gap-10 p-5 justify-center items-center mx-auto">
{albums.map((album: any) => (
<div className="flex flex-col gap-10 p-5 justify-center items-center mx-auto shadow-sm hover:shadow-2xl transition-shadow duration-500 ease-in-out">
<img src={album.images[0].url} alt="album" />
<h3>{album.name}</h3>
<p>{album.artists[0].name}</p>
</div>
))}
</div>
`
)