diff --git a/.gitpod.yml b/.gitpod.yml index ef5fb40..56b8af3 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,5 +1,17 @@ + image: file: .gitpod.Dockerfile tasks: + # Install packages, preloads user's librc in its base64-encoded form and decode back to ~/.librc - init: | - npm install \ No newline at end of file + npm install + before: | + eval $(gp env -e) + if [[ $STDLIBRC != "" ]]; then + echo $STDLIBRC | base64 -d | tee ~/.librc.test >> /dev/null + fi + command: npn run dev +vscode: + extensions: + - GitLab.gitlab-workflow + - exiasr.hadolint diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..eb3e1f5 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "gitlab.gitlab-workflow", + "exiasr.hadolint" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 51af31f..80d86db 100755 --- a/README.md +++ b/README.md @@ -1,18 +1,29 @@ -# verify.rtapp.io backend +# Verification Endpoint API backend -This is the backend code the Recap Time Squad is using on our. This project is helpful on those who maintain their own fork of -the repo in both GitHub and GitLab repos. It's still an work in progress througn, but if you like to contribute, ask @ajhalili2006 -over Discord (check the links below) +[![Open in gitpod](https://img.shields.io/badge/Gitpod-ready--to--code-908a85?logo=gitpod)](https://gitpod.io/#https://gitlab.com/RecapTime/infra/rtapp-verify-backend-autocode) + +This is our source code for the Verification Endpoint API handler and Discord bot running on Autocode, usually synchorized every hour through GitLab CI. + +API calls from `verify.rtapp.` domain will be trnsparently redirected to the production release at `rtapp-verify-backend.recaptime.autocode.gg`. + +## Development + +Requires Node.js 14+ and Autocode CLI if you want to do local development or even deployment to development/production environments on Autocode. + +### Setup + +1. `npm install` +2. `npm start` to run an local FunctionScript gateway with hot reload included. +3. `curl -i http://localhost:8170/recaptime/rtapp-verify-backend/ping` ## Getting help -* Discord: For Autocode users who are in the official Autocode Discord sevrer, just ping Andrei Jiroh (`Andrei Jiroh#`). -You can also optionally join +* Discord: For Autocode users who are in [the official Autocode Discord sevrer](https://discord.gg/autocode) or Miraheze users on Miraheze Discord, just ping Andrei Jiroh (`Andrei Jiroh#7159`). You can also optionally [join Recap Time Squad's Discord server](https://discord.gg/5dURUcM) and ask for help under `#rtapp-verify-bot` channel. +* Issue tracker: We track issues on instead. ## Related Projects -* [Main rtapp-verify repo](https://gitlab.com/RecapTime/verify) ([GitHub mirror](https://github.com/RecapTime/verify) is available -through we use issue forms) - where all the +* [Main project repo](https://gitlab.com/RecapTime/verify) ([GitHub mirror](https://github.com/RecapTime/verify) is available through we use issue forms) - all the verification metadata are being stored publicly, through some private data are held in an MongoDB database instead. ## Credits diff --git a/lib/secrets.js b/lib/secrets.js index 8a50dec..f9d4afd 100644 --- a/lib/secrets.js +++ b/lib/secrets.js @@ -1,6 +1,7 @@ /** * Environment variable loader from our env.json file (omitted from GitLab code export due to potential leakage - * of secrets). It is usually loaded when + * of secrets). It is usually loaded at top of most of the functions and usually used at local development and + * when doing API development using Gitpod/containers. */ function loadEnvFromFile() { const fs = require('fs'); @@ -8,12 +9,20 @@ function loadEnvFromFile() { fs.access("/opt/node_modules/autocode-common/configs", (err) => { if (err) { fs.access('env.json', (err) => { + /** + * If env.json exists locally, attempt to load them automagically within the Node.js process. + */ const env = require("../env.json") if (!err) { - process.env["MONGO_DATABASE"] = env.dev.MONGO_DATABASE - process.env["DISCORD_GUILD_ID"] = env.dev.DISCORD_GUILD_ID, - process.env["DISCORD_ROLE_ID"] = env.dev.DISCORD_GUILD_ID + process.env.MONGO_DATABASE = env.dev.MONGO_DATABASE + process.env.DISCORD_GUILD_ID = env.dev.DISCORD_GUILD_ID, + process.env.DISCORD_ROLE_ID = env.dev.DISCORD_GUILD_ID, + process.env.MW_OAUTH_CLIENT_ID = env.dev.MW_OAUTH_CLIENT_ID, + process.env.MW_OAUTH_CLIENT_SECRET = env.dev.MW_OAUTH_CLIENT_SECRET, + process.env.MW_MW_OAUTH_CALLBACK = env.dev.MW_OAUTH_CALLBACK, + process.env.MW_OAUTH_ROOT = env.dev.MW_OAUTH_ROOT } else { + /** Otherwise, preload secrets using dotenv */ require("dotenv").config() } }) diff --git a/package.json b/package.json index f123baa..7a1ca04 100755 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "publish": false, "scripts": { "start": "lib http", - "dev": "nodemon --exec \"lib http\"", + "dev": "npm run start", "deploy:dev": "lib up dev", "deploy:prod": "lib release" }, diff --git a/readme/.empty b/readme/.empty new file mode 100755 index 0000000..e69de29