diff --git a/babashka/scripts.json b/babashka/scripts.json index 6122e65..28eb68c 100644 --- a/babashka/scripts.json +++ b/babashka/scripts.json @@ -1,4 +1,3 @@ [ - { "file": "pst.clj", "route": "/bb/getPstTime", "method": "GET" }, - { "file": "latest-release.clj", "route": "/bb/sernRelease", "method": "GET" } + { "file": "pst.clj", "route": "/bb/getPstTime", "method": "GET" } ] diff --git a/index.ts b/index.ts index 2649484..34e649d 100644 --- a/index.ts +++ b/index.ts @@ -6,7 +6,6 @@ import babashkaScripts from './babashka/scripts.json' assert { type: 'json' }; import PocketBase from 'pocketbase'; import { FeedbackRecord } from './util/pbtypes.js'; import { FeedbackRequestBody } from './util/types.js'; -import axios from 'axios'; import FormData from 'form-data'; import cors from 'cors' import rateLimit from 'express-rate-limit'; @@ -90,10 +89,13 @@ app.post('/tutorial/feedback', feedbackRateLimit, async (req, res) => { }); // part where turnstile token gets validated - const turnstileFormData = new FormData() + const turnstileFormData = new URLSearchParams() turnstileFormData.append('response', body.turnstileToken) - turnstileFormData.append('secret', process.env.TURNSTILE_SECRET) - const turnstileResponse = await axios.post('https://challenges.cloudflare.com/turnstile/v0/siteverify', turnstileFormData).then(res => res.data) + turnstileFormData.append('secret', process.env.TURNSTILE_SECRET!) + const turnstileResponse = await fetch('https://challenges.cloudflare.com/turnstile/v0/siteverify', { + method: 'POST', + body: turnstileFormData + }).then(res => res.json()) if (!turnstileResponse.success) return res .status(403) @@ -115,7 +117,7 @@ app.post('/tutorial/feedback', feedbackRateLimit, async (req, res) => { }); // webhook - const webhook = new Webhook(new URL(process.env.DEV_WEBHOOK!), 'sern Guide Feedback (by automata)', 'https://avatars.githubusercontent.com/u/129876409?v=4') + const webhook = new Webhook(new URL(process.env.DEV_WEBHOOK!), 'Guide Feedback (by automata)', 'https://avatars.githubusercontent.com/u/129876409?v=4') const upvoteCount = (await pb.collection('feedback').getFullList({ filter: `feedback = 'up' && route = '${body.route}'` })).length const downvoteCount = (await pb.collection('feedback').getFullList({ filter: `feedback = 'down' && route = '${body.route}'` })).length webhook.send(`Feedback recorded for ${body.route}!`, [{ diff --git a/package.json b/package.json index e2cf721..8fefb47 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ }, "type": "module", "dependencies": { - "axios": "^1.5.0", "body-parser": "^1.20.2", "cors": "^2.8.5", "dotenv": "^16.0.3",