aboutsummaryrefslogtreecommitdiff
path: root/src/datasources/senpy.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/datasources/senpy.js')
-rw-r--r--src/datasources/senpy.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/datasources/senpy.js b/src/datasources/senpy.js
new file mode 100644
index 0000000..1d9ba2a
--- /dev/null
+++ b/src/datasources/senpy.js
@@ -0,0 +1,27 @@
+const { RESTDataSource } = require("apollo-datasource-rest");
+
+module.exports = class SenpyAPI extends RESTDataSource {
+ constructor() {
+ super();
+
+ /**
+ * We have to use the <workers.dev> domain instead of the custom domain
+ * because worker intercommunication still isn't a thing...
+ *
+ * Tracking: <https://community.cloudflare.com/t/issue-with-worker-to-worker-https-request/94472>
+ */
+ this.baseURL = "https://senpy-club-api-worker.fuwn.workers.dev/v2/";
+ }
+
+ async getRandom() {
+ return this.get("random");
+ }
+
+ async getLanguages() {
+ return this.get("languages");
+ }
+
+ async getLanguage(language) {
+ return this.get(`language/${language}`);
+ }
+};