From c25539aae5d7737cf1f2a5551c5fc41cdde0d074 Mon Sep 17 00:00:00 2001 From: Andrei Jiroh Eugenio Halili Date: Thu, 28 Apr 2022 12:11:26 +0000 Subject: [PATCH] feat(global): :sparkles: add OpenAPI definition and Axios custom user agent magic Also we updated package.json to include repository object for use in the lib/userAgent.js file. Signed-off-by: Andrei Jiroh Eugenio Halili --- lib/userAgent.js | 8 ++++++ package.json | 4 +++ scripts/update-oas-wiki.js | 8 ++++++ www/openapi.yaml | 57 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 lib/userAgent.js create mode 100755 scripts/update-oas-wiki.js create mode 100644 www/openapi.yaml diff --git a/lib/userAgent.js b/lib/userAgent.js new file mode 100644 index 0000000..a4af3d8 --- /dev/null +++ b/lib/userAgent.js @@ -0,0 +1,8 @@ +module.exports = () => { + if (!process.env.USER_AGENT_HTTP_CLIENT) { + const { name, version, repository }= require("../package.json") + return `${name}@${version}, ${repository.url}` + } else { + return process.env.USER_AGENT_HTTP_CLIENT + } +} \ No newline at end of file diff --git a/package.json b/package.json index e7bed68..3da616a 100755 --- a/package.json +++ b/package.json @@ -3,6 +3,10 @@ "author": "Andrei Jiroh Halili ", "version": "0.1.0", "license": "MIT", + "repository": { + "url": "https://gitlab.com/RecapTime/infra/rtapp-verify-backend-autocode", + "type": "git" + }, "publish": false, "scripts": { "start": "lib http", diff --git a/scripts/update-oas-wiki.js b/scripts/update-oas-wiki.js new file mode 100755 index 0000000..2695df4 --- /dev/null +++ b/scripts/update-oas-wiki.js @@ -0,0 +1,8 @@ +#!/usr/bin/env node +const { readFileSync } = require('fs'); +const axios = require("axios") +const apiBase = axios.todo; + +var yamlData = readFileSync("./www/openapi.yaml", 'utf8') +var encodedData = encodeURIComponent(yamlData) +console.log("URL-encoded YAML data:", encodedData) \ No newline at end of file diff --git a/www/openapi.yaml b/www/openapi.yaml new file mode 100644 index 0000000..942f5c2 --- /dev/null +++ b/www/openapi.yaml @@ -0,0 +1,57 @@ +# SPDX-LICENSE: MIT +# +openapi: 3.0.3 +info: + title: Verification Endpoint API + termsOfService: https://policy.recaptime.eu.org/api-terms + version: doc 0.1.0 +servers: + - url: https://dev--rtapp-verify-backend.recaptime.autocode.gg + description: development + - url: https://rtapp-verify-backend.recaptime.autocode.gg + description: production +tags: + - name: meta + - name: Index Lookup + - name: Requires Authentication + - name: OAuth + - name: Webhooks + - name: Admin-only / Debug +components: + securitySchemes: + bearerToken: + type: http + scheme: bearer +paths: + /ping/: + get: + summary: Pings Autocode servers whenever the deployment is up. + tags: + - meta + responses: + 200: + description: Everything is up. + content: + application/json: + schema: + type: object + properties: + ok: + type: boolean + example: true + ping: + type: string + example: "Pong!" + /lookup/me/: + get: + security: + - bearerToken: [] + summary: Query yourself based on current authenticated user. + tags: + - Requires Authentication + - Index Lookup + /oauth/mediawiki/: + get: + summary: | + Endpoint used by integration bots built by Recap Time Squad for +# \ No newline at end of file