Initial commit

This commit is contained in:
2025-04-07 12:59:20 +03:00
commit d47a21fcbf
47 changed files with 12696 additions and 0 deletions

34
server/plugins/webhook.ts Normal file
View File

@@ -0,0 +1,34 @@
import { isEmpty } from "radash";
import { URLSearchParams } from "url";
export default defineNitroPlugin(() => {
onHubReady(async () => {
const config = useRuntimeConfig();
const webhooks = await $fetch(
"https://www.strava.com/api/v3/push_subscriptions",
{
params: {
client_id: config.oauth.strava.clientId,
client_secret: config.oauth.strava.clientSecret,
},
},
);
if (!isEmpty(webhooks)) {
return;
}
await $fetch("https://www.strava.com/api/v3/push_subscriptions", {
method: "post",
body: new URLSearchParams({
client_id: config.oauth.strava.clientId,
client_secret: config.oauth.strava.clientSecret,
callback_url: config.webhooksUrl,
verify_token: config.stravaVerifyToken,
}),
});
console.log("Webhook registered successfully!");
});
});