From 9beb3135fbdf1cae6ed49709358480d0e28f34e5 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sat, 17 Feb 2024 04:40:09 +0000 Subject: [PATCH 01/14] Restructure Project Files into Distinct Folders --- .github/workflows/frontend-tests.yml | 26 ++++++++++++++++++ .../.eslintrc.json | 0 .gitignore => frontend-next/.gitignore | 1 + README.md => frontend-next/README.md | 0 jsconfig.json => frontend-next/jsconfig.json | 0 .../next.config.mjs | 0 .../package-lock.json | 0 package.json => frontend-next/package.json | 0 .../postcss.config.js | 0 {public => frontend-next/public}/next.svg | 0 {public => frontend-next/public}/vercel.svg | 0 {src => frontend-next/src}/app/favicon.ico | Bin {src => frontend-next/src}/app/globals.css | 0 {src => frontend-next/src}/app/layout.js | 0 {src => frontend-next/src}/app/page.js | 0 .../tailwind.config.js | 0 16 files changed, 27 insertions(+) create mode 100644 .github/workflows/frontend-tests.yml rename .eslintrc.json => frontend-next/.eslintrc.json (100%) rename .gitignore => frontend-next/.gitignore (93%) rename README.md => frontend-next/README.md (100%) rename jsconfig.json => frontend-next/jsconfig.json (100%) rename next.config.mjs => frontend-next/next.config.mjs (100%) rename package-lock.json => frontend-next/package-lock.json (100%) rename package.json => frontend-next/package.json (100%) rename postcss.config.js => frontend-next/postcss.config.js (100%) rename {public => frontend-next/public}/next.svg (100%) rename {public => frontend-next/public}/vercel.svg (100%) rename {src => frontend-next/src}/app/favicon.ico (100%) rename {src => frontend-next/src}/app/globals.css (100%) rename {src => frontend-next/src}/app/layout.js (100%) rename {src => frontend-next/src}/app/page.js (100%) rename tailwind.config.js => frontend-next/tailwind.config.js (100%) diff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.yml new file mode 100644 index 0000000..dfbcecc --- /dev/null +++ b/.github/workflows/frontend-tests.yml @@ -0,0 +1,26 @@ +name: Next.Js Build Validation + +on: + pull_request: + push: + branches: + - "main" + +jobs: + nextjs: + runs-on: ubuntu-latest + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: 21.6.2 + + - name: Install dependencies + run: npm install frontend-next/ + + - name: Buide + run: npm --prefix frontend-next/ run build diff --git a/.eslintrc.json b/frontend-next/.eslintrc.json similarity index 100% rename from .eslintrc.json rename to frontend-next/.eslintrc.json diff --git a/.gitignore b/frontend-next/.gitignore similarity index 93% rename from .gitignore rename to frontend-next/.gitignore index fd3dbb5..ea3d442 100644 --- a/.gitignore +++ b/frontend-next/.gitignore @@ -34,3 +34,4 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts +frontend-next/node_modules \ No newline at end of file diff --git a/README.md b/frontend-next/README.md similarity index 100% rename from README.md rename to frontend-next/README.md diff --git a/jsconfig.json b/frontend-next/jsconfig.json similarity index 100% rename from jsconfig.json rename to frontend-next/jsconfig.json diff --git a/next.config.mjs b/frontend-next/next.config.mjs similarity index 100% rename from next.config.mjs rename to frontend-next/next.config.mjs diff --git a/package-lock.json b/frontend-next/package-lock.json similarity index 100% rename from package-lock.json rename to frontend-next/package-lock.json diff --git a/package.json b/frontend-next/package.json similarity index 100% rename from package.json rename to frontend-next/package.json diff --git a/postcss.config.js b/frontend-next/postcss.config.js similarity index 100% rename from postcss.config.js rename to frontend-next/postcss.config.js diff --git a/public/next.svg b/frontend-next/public/next.svg similarity index 100% rename from public/next.svg rename to frontend-next/public/next.svg diff --git a/public/vercel.svg b/frontend-next/public/vercel.svg similarity index 100% rename from public/vercel.svg rename to frontend-next/public/vercel.svg diff --git a/src/app/favicon.ico b/frontend-next/src/app/favicon.ico similarity index 100% rename from src/app/favicon.ico rename to frontend-next/src/app/favicon.ico diff --git a/src/app/globals.css b/frontend-next/src/app/globals.css similarity index 100% rename from src/app/globals.css rename to frontend-next/src/app/globals.css diff --git a/src/app/layout.js b/frontend-next/src/app/layout.js similarity index 100% rename from src/app/layout.js rename to frontend-next/src/app/layout.js diff --git a/src/app/page.js b/frontend-next/src/app/page.js similarity index 100% rename from src/app/page.js rename to frontend-next/src/app/page.js diff --git a/tailwind.config.js b/frontend-next/tailwind.config.js similarity index 100% rename from tailwind.config.js rename to frontend-next/tailwind.config.js -- 2.52.0 From cbaf8cae3aa63993e707065b68c4b096cc978106 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sat, 17 Feb 2024 04:50:44 +0000 Subject: [PATCH 02/14] Typo in final step of frontend-tests.yml --- .github/workflows/frontend-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.yml index dfbcecc..e54297d 100644 --- a/.github/workflows/frontend-tests.yml +++ b/.github/workflows/frontend-tests.yml @@ -22,5 +22,5 @@ jobs: - name: Install dependencies run: npm install frontend-next/ - - name: Buide + - name: Build run: npm --prefix frontend-next/ run build -- 2.52.0 From c3befbcebde2b2d43f29b54b17c00771b3ad42f6 Mon Sep 17 00:00:00 2001 From: Nicholas Pease <34464552+LAX18@users.noreply.github.com> Date: Sat, 17 Feb 2024 00:05:54 -0500 Subject: [PATCH 03/14] Restore original README --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9dc6949 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# ChatMaps +Main repo for ChatMaps, our COS420 Project. -- 2.52.0 From f49c18f712fc54b508d95439132f37a9fb1e2fb9 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 01:03:01 +0000 Subject: [PATCH 04/14] Update frontend tests --- .github/workflows/frontend-tests.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.yml index 5d97a0b..b1c4c1b 100644 --- a/.github/workflows/frontend-tests.yml +++ b/.github/workflows/frontend-tests.yml @@ -1,4 +1,4 @@ -name: Next.Js Build Validation +name: Frontend Next.Js Build Validation on: pull_request: @@ -22,5 +22,8 @@ jobs: - name: Install dependencies run: npm install frontend-next/ - - name: Build + - name: Lint + run: npm --prefix frontend-next/ run lint + + - name: Build Frontend run: npm --prefix frontend-next/ run build \ No newline at end of file -- 2.52.0 From c5ba2fbcf833cbe101369e481552c14f5bd1791c Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 01:28:40 +0000 Subject: [PATCH 05/14] Webhook shell, ready for server testing --- backend/.gitignore | 1 + backend/api.js | 10 + backend/package-lock.json | 690 ++++++++++++++++++++++++++++++++++++++ backend/package.json | 5 + 4 files changed, 706 insertions(+) create mode 100644 backend/.gitignore create mode 100644 backend/api.js create mode 100644 backend/package-lock.json create mode 100644 backend/package.json diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/backend/api.js b/backend/api.js new file mode 100644 index 0000000..a8e139a --- /dev/null +++ b/backend/api.js @@ -0,0 +1,10 @@ +const express = require("express") +const app = express() + +// Uses nodejs and express as "basic" backend server +// Recieves webhook from Github at https://chatmaps.nicholaspease.com/api/v1/deploy +app.post("/deploy", function (req, res) { + console.log(req.body) +}) + +app.listen(8000) \ No newline at end of file diff --git a/backend/package-lock.json b/backend/package-lock.json new file mode 100644 index 0000000..3ca502e --- /dev/null +++ b/backend/package-lock.json @@ -0,0 +1,690 @@ +{ + "name": "backend", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "express": "^4.18.2" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, + "node_modules/body-parser": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.1", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.5.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz", + "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/send": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.18.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/set-function-length": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", + "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==", + "dependencies": { + "define-data-property": "^1.1.2", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.3", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "node_modules/side-channel": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.5.tgz", + "integrity": "sha512-QcgiIWV4WV7qWExbN5llt6frQB/lBven9pqliLXfGPB+K9ZYXxDozp0wLkHS24kWCm+6YXH/f0HhnObZnZOBnQ==", + "dependencies": { + "call-bind": "^1.0.6", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + } + } +} diff --git a/backend/package.json b/backend/package.json new file mode 100644 index 0000000..0e6cd98 --- /dev/null +++ b/backend/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "express": "^4.18.2" + } +} -- 2.52.0 From 9da1b6c78c74c6b68b3ada117950b5ea4f1f9687 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 01:42:44 +0000 Subject: [PATCH 06/14] Extend post route --- backend/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/api.js b/backend/api.js index a8e139a..fb7ccc3 100644 --- a/backend/api.js +++ b/backend/api.js @@ -3,7 +3,7 @@ const app = express() // Uses nodejs and express as "basic" backend server // Recieves webhook from Github at https://chatmaps.nicholaspease.com/api/v1/deploy -app.post("/deploy", function (req, res) { +app.post("/api/v1/deploy", function (req, res) { console.log(req.body) }) -- 2.52.0 From fd82639658c788fb93c623166fdb7ddcbea7a384 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 02:09:01 +0000 Subject: [PATCH 07/14] Proper routing and parsing for test condition --- backend/api.js | 8 ++++++ backend/package-lock.json | 54 +++++++++++++++++++++++++++++++++------ backend/package.json | 1 + 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/backend/api.js b/backend/api.js index fb7ccc3..7d6d88d 100644 --- a/backend/api.js +++ b/backend/api.js @@ -1,10 +1,18 @@ const express = require("express") const app = express() +const bodyParser = require("body-parser") +app.use(bodyParser.urlencoded({ extended: false })); +app.use(bodyParser.json()); // Uses nodejs and express as "basic" backend server // Recieves webhook from Github at https://chatmaps.nicholaspease.com/api/v1/deploy app.post("/api/v1/deploy", function (req, res) { console.log(req.body) + res.send("OK") +}) + +app.get('/api/v1', (req, res) => { + res.send('Hello World!') }) app.listen(8000) \ No newline at end of file diff --git a/backend/package-lock.json b/backend/package-lock.json index 3ca502e..e86e205 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -5,6 +5,7 @@ "packages": { "": { "dependencies": { + "body-parser": "^1.20.2", "express": "^4.18.2" } }, @@ -26,12 +27,12 @@ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" }, "node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dependencies": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -39,7 +40,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -233,6 +234,43 @@ "node": ">= 0.10.0" } }, + "node_modules/express/node_modules/body-parser": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/express/node_modules/raw-body": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/finalhandler": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", @@ -517,9 +555,9 @@ } }, "node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", diff --git a/backend/package.json b/backend/package.json index 0e6cd98..d2ae197 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "body-parser": "^1.20.2", "express": "^4.18.2" } } -- 2.52.0 From c86d9275e749cd343384cfe0e415631cf33693c7 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 02:19:01 +0000 Subject: [PATCH 08/14] Restructure Folder Structure --- backend/{ => server_update_hook}/.gitignore | 0 backend/{ => server_update_hook}/api.js | 3 +- backend/server_update_hook/example_PR.json | 521 ++++++++++++++++++ .../package-lock.json | 0 backend/{ => server_update_hook}/package.json | 0 5 files changed, 523 insertions(+), 1 deletion(-) rename backend/{ => server_update_hook}/.gitignore (100%) rename backend/{ => server_update_hook}/api.js (86%) create mode 100644 backend/server_update_hook/example_PR.json rename backend/{ => server_update_hook}/package-lock.json (100%) rename backend/{ => server_update_hook}/package.json (100%) diff --git a/backend/.gitignore b/backend/server_update_hook/.gitignore similarity index 100% rename from backend/.gitignore rename to backend/server_update_hook/.gitignore diff --git a/backend/api.js b/backend/server_update_hook/api.js similarity index 86% rename from backend/api.js rename to backend/server_update_hook/api.js index 7d6d88d..47728c3 100644 --- a/backend/api.js +++ b/backend/server_update_hook/api.js @@ -11,8 +11,9 @@ app.post("/api/v1/deploy", function (req, res) { res.send("OK") }) +// Generic endpoint, useful to test if updater is alive app.get('/api/v1', (req, res) => { - res.send('Hello World!') + res.send('OK') }) app.listen(8000) \ No newline at end of file diff --git a/backend/server_update_hook/example_PR.json b/backend/server_update_hook/example_PR.json new file mode 100644 index 0000000..a8333c7 --- /dev/null +++ b/backend/server_update_hook/example_PR.json @@ -0,0 +1,521 @@ +{ + "action": "closed", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1", + "id": 1731422439, + "node_id": "PR_kwDOLUDxO85nM2jn", + "html_url": "https://github.com/LAX18/ChatMaps/pull/1", + "diff_url": "https://github.com/LAX18/ChatMaps/pull/1.diff", + "patch_url": "https://github.com/LAX18/ChatMaps/pull/1.patch", + "issue_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/1", + "number": 1, + "state": "closed", + "locked": false, + "title": "Npease server update hook", + "user": { + "login": "LAX18", + "id": 34464552, + "node_id": "MDQ6VXNlcjM0NDY0NTUy", + "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/LAX18", + "html_url": "https://github.com/LAX18", + "followers_url": "https://api.github.com/users/LAX18/followers", + "following_url": "https://api.github.com/users/LAX18/following{/other_user}", + "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", + "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", + "organizations_url": "https://api.github.com/users/LAX18/orgs", + "repos_url": "https://api.github.com/users/LAX18/repos", + "events_url": "https://api.github.com/users/LAX18/events{/privacy}", + "received_events_url": "https://api.github.com/users/LAX18/received_events", + "type": "User", + "site_admin": false + }, + "body": null, + "created_at": "2024-02-18T02:14:48Z", + "updated_at": "2024-02-18T02:15:25Z", + "closed_at": "2024-02-18T02:15:25Z", + "merged_at": "2024-02-18T02:15:25Z", + "merge_commit_sha": "2e4fbaf6c30f82507ec7cff7895e57bc9de562b7", + "assignee": null, + "assignees": [ + + ], + "requested_reviewers": [ + + ], + "requested_teams": [ + + ], + "labels": [ + + ], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1/commits", + "review_comments_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1/comments", + "review_comment_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/1/comments", + "statuses_url": "https://api.github.com/repos/LAX18/ChatMaps/statuses/fd82639658c788fb93c623166fdb7ddcbea7a384", + "head": { + "label": "LAX18:npease-server-update-hook", + "ref": "npease-server-update-hook", + "sha": "fd82639658c788fb93c623166fdb7ddcbea7a384", + "user": { + "login": "LAX18", + "id": 34464552, + "node_id": "MDQ6VXNlcjM0NDY0NTUy", + "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/LAX18", + "html_url": "https://github.com/LAX18", + "followers_url": "https://api.github.com/users/LAX18/followers", + "following_url": "https://api.github.com/users/LAX18/following{/other_user}", + "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", + "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", + "organizations_url": "https://api.github.com/users/LAX18/orgs", + "repos_url": "https://api.github.com/users/LAX18/repos", + "events_url": "https://api.github.com/users/LAX18/events{/privacy}", + "received_events_url": "https://api.github.com/users/LAX18/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 759230779, + "node_id": "R_kgDOLUDxOw", + "name": "ChatMaps", + "full_name": "LAX18/ChatMaps", + "private": false, + "owner": { + "login": "LAX18", + "id": 34464552, + "node_id": "MDQ6VXNlcjM0NDY0NTUy", + "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/LAX18", + "html_url": "https://github.com/LAX18", + "followers_url": "https://api.github.com/users/LAX18/followers", + "following_url": "https://api.github.com/users/LAX18/following{/other_user}", + "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", + "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", + "organizations_url": "https://api.github.com/users/LAX18/orgs", + "repos_url": "https://api.github.com/users/LAX18/repos", + "events_url": "https://api.github.com/users/LAX18/events{/privacy}", + "received_events_url": "https://api.github.com/users/LAX18/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/LAX18/ChatMaps", + "description": "Main repo for ChatMaps, COS420 Project", + "fork": true, + "url": "https://api.github.com/repos/LAX18/ChatMaps", + "forks_url": "https://api.github.com/repos/LAX18/ChatMaps/forks", + "keys_url": "https://api.github.com/repos/LAX18/ChatMaps/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/LAX18/ChatMaps/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/LAX18/ChatMaps/teams", + "hooks_url": "https://api.github.com/repos/LAX18/ChatMaps/hooks", + "issue_events_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/events{/number}", + "events_url": "https://api.github.com/repos/LAX18/ChatMaps/events", + "assignees_url": "https://api.github.com/repos/LAX18/ChatMaps/assignees{/user}", + "branches_url": "https://api.github.com/repos/LAX18/ChatMaps/branches{/branch}", + "tags_url": "https://api.github.com/repos/LAX18/ChatMaps/tags", + "blobs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/LAX18/ChatMaps/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/LAX18/ChatMaps/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/LAX18/ChatMaps/statuses/{sha}", + "languages_url": "https://api.github.com/repos/LAX18/ChatMaps/languages", + "stargazers_url": "https://api.github.com/repos/LAX18/ChatMaps/stargazers", + "contributors_url": "https://api.github.com/repos/LAX18/ChatMaps/contributors", + "subscribers_url": "https://api.github.com/repos/LAX18/ChatMaps/subscribers", + "subscription_url": "https://api.github.com/repos/LAX18/ChatMaps/subscription", + "commits_url": "https://api.github.com/repos/LAX18/ChatMaps/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/LAX18/ChatMaps/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/LAX18/ChatMaps/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/LAX18/ChatMaps/contents/{+path}", + "compare_url": "https://api.github.com/repos/LAX18/ChatMaps/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/LAX18/ChatMaps/merges", + "archive_url": "https://api.github.com/repos/LAX18/ChatMaps/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/LAX18/ChatMaps/downloads", + "issues_url": "https://api.github.com/repos/LAX18/ChatMaps/issues{/number}", + "pulls_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls{/number}", + "milestones_url": "https://api.github.com/repos/LAX18/ChatMaps/milestones{/number}", + "notifications_url": "https://api.github.com/repos/LAX18/ChatMaps/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/LAX18/ChatMaps/labels{/name}", + "releases_url": "https://api.github.com/repos/LAX18/ChatMaps/releases{/id}", + "deployments_url": "https://api.github.com/repos/LAX18/ChatMaps/deployments", + "created_at": "2024-02-18T02:13:20Z", + "updated_at": "2024-02-18T02:13:20Z", + "pushed_at": "2024-02-18T02:15:25Z", + "git_url": "git://github.com/LAX18/ChatMaps.git", + "ssh_url": "git@github.com:LAX18/ChatMaps.git", + "clone_url": "https://github.com/LAX18/ChatMaps.git", + "svn_url": "https://github.com/LAX18/ChatMaps", + "homepage": "", + "size": 82, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "LAX18:main", + "ref": "main", + "sha": "d05153ce683fc4c3a7f6fd0414d74f785c9e0fb6", + "user": { + "login": "LAX18", + "id": 34464552, + "node_id": "MDQ6VXNlcjM0NDY0NTUy", + "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/LAX18", + "html_url": "https://github.com/LAX18", + "followers_url": "https://api.github.com/users/LAX18/followers", + "following_url": "https://api.github.com/users/LAX18/following{/other_user}", + "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", + "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", + "organizations_url": "https://api.github.com/users/LAX18/orgs", + "repos_url": "https://api.github.com/users/LAX18/repos", + "events_url": "https://api.github.com/users/LAX18/events{/privacy}", + "received_events_url": "https://api.github.com/users/LAX18/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 759230779, + "node_id": "R_kgDOLUDxOw", + "name": "ChatMaps", + "full_name": "LAX18/ChatMaps", + "private": false, + "owner": { + "login": "LAX18", + "id": 34464552, + "node_id": "MDQ6VXNlcjM0NDY0NTUy", + "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/LAX18", + "html_url": "https://github.com/LAX18", + "followers_url": "https://api.github.com/users/LAX18/followers", + "following_url": "https://api.github.com/users/LAX18/following{/other_user}", + "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", + "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", + "organizations_url": "https://api.github.com/users/LAX18/orgs", + "repos_url": "https://api.github.com/users/LAX18/repos", + "events_url": "https://api.github.com/users/LAX18/events{/privacy}", + "received_events_url": "https://api.github.com/users/LAX18/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/LAX18/ChatMaps", + "description": "Main repo for ChatMaps, COS420 Project", + "fork": true, + "url": "https://api.github.com/repos/LAX18/ChatMaps", + "forks_url": "https://api.github.com/repos/LAX18/ChatMaps/forks", + "keys_url": "https://api.github.com/repos/LAX18/ChatMaps/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/LAX18/ChatMaps/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/LAX18/ChatMaps/teams", + "hooks_url": "https://api.github.com/repos/LAX18/ChatMaps/hooks", + "issue_events_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/events{/number}", + "events_url": "https://api.github.com/repos/LAX18/ChatMaps/events", + "assignees_url": "https://api.github.com/repos/LAX18/ChatMaps/assignees{/user}", + "branches_url": "https://api.github.com/repos/LAX18/ChatMaps/branches{/branch}", + "tags_url": "https://api.github.com/repos/LAX18/ChatMaps/tags", + "blobs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/LAX18/ChatMaps/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/LAX18/ChatMaps/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/LAX18/ChatMaps/statuses/{sha}", + "languages_url": "https://api.github.com/repos/LAX18/ChatMaps/languages", + "stargazers_url": "https://api.github.com/repos/LAX18/ChatMaps/stargazers", + "contributors_url": "https://api.github.com/repos/LAX18/ChatMaps/contributors", + "subscribers_url": "https://api.github.com/repos/LAX18/ChatMaps/subscribers", + "subscription_url": "https://api.github.com/repos/LAX18/ChatMaps/subscription", + "commits_url": "https://api.github.com/repos/LAX18/ChatMaps/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/LAX18/ChatMaps/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/LAX18/ChatMaps/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/LAX18/ChatMaps/contents/{+path}", + "compare_url": "https://api.github.com/repos/LAX18/ChatMaps/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/LAX18/ChatMaps/merges", + "archive_url": "https://api.github.com/repos/LAX18/ChatMaps/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/LAX18/ChatMaps/downloads", + "issues_url": "https://api.github.com/repos/LAX18/ChatMaps/issues{/number}", + "pulls_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls{/number}", + "milestones_url": "https://api.github.com/repos/LAX18/ChatMaps/milestones{/number}", + "notifications_url": "https://api.github.com/repos/LAX18/ChatMaps/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/LAX18/ChatMaps/labels{/name}", + "releases_url": "https://api.github.com/repos/LAX18/ChatMaps/releases{/id}", + "deployments_url": "https://api.github.com/repos/LAX18/ChatMaps/deployments", + "created_at": "2024-02-18T02:13:20Z", + "updated_at": "2024-02-18T02:13:20Z", + "pushed_at": "2024-02-18T02:15:25Z", + "git_url": "git://github.com/LAX18/ChatMaps.git", + "ssh_url": "git@github.com:LAX18/ChatMaps.git", + "clone_url": "https://github.com/LAX18/ChatMaps.git", + "svn_url": "https://github.com/LAX18/ChatMaps", + "homepage": "", + "size": 82, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1" + }, + "html": { + "href": "https://github.com/LAX18/ChatMaps/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/LAX18/ChatMaps/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/LAX18/ChatMaps/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/LAX18/ChatMaps/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/LAX18/ChatMaps/statuses/fd82639658c788fb93c623166fdb7ddcbea7a384" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "active_lock_reason": null, + "merged": true, + "mergeable": null, + "rebaseable": null, + "mergeable_state": "unknown", + "merged_by": { + "login": "LAX18", + "id": 34464552, + "node_id": "MDQ6VXNlcjM0NDY0NTUy", + "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/LAX18", + "html_url": "https://github.com/LAX18", + "followers_url": "https://api.github.com/users/LAX18/followers", + "following_url": "https://api.github.com/users/LAX18/following{/other_user}", + "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", + "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", + "organizations_url": "https://api.github.com/users/LAX18/orgs", + "repos_url": "https://api.github.com/users/LAX18/repos", + "events_url": "https://api.github.com/users/LAX18/events{/privacy}", + "received_events_url": "https://api.github.com/users/LAX18/received_events", + "type": "User", + "site_admin": false + }, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 8, + "additions": 798, + "deletions": 39, + "changed_files": 21 + }, + "repository": { + "id": 759230779, + "node_id": "R_kgDOLUDxOw", + "name": "ChatMaps", + "full_name": "LAX18/ChatMaps", + "private": false, + "owner": { + "login": "LAX18", + "id": 34464552, + "node_id": "MDQ6VXNlcjM0NDY0NTUy", + "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/LAX18", + "html_url": "https://github.com/LAX18", + "followers_url": "https://api.github.com/users/LAX18/followers", + "following_url": "https://api.github.com/users/LAX18/following{/other_user}", + "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", + "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", + "organizations_url": "https://api.github.com/users/LAX18/orgs", + "repos_url": "https://api.github.com/users/LAX18/repos", + "events_url": "https://api.github.com/users/LAX18/events{/privacy}", + "received_events_url": "https://api.github.com/users/LAX18/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/LAX18/ChatMaps", + "description": "Main repo for ChatMaps, COS420 Project", + "fork": true, + "url": "https://api.github.com/repos/LAX18/ChatMaps", + "forks_url": "https://api.github.com/repos/LAX18/ChatMaps/forks", + "keys_url": "https://api.github.com/repos/LAX18/ChatMaps/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/LAX18/ChatMaps/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/LAX18/ChatMaps/teams", + "hooks_url": "https://api.github.com/repos/LAX18/ChatMaps/hooks", + "issue_events_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/events{/number}", + "events_url": "https://api.github.com/repos/LAX18/ChatMaps/events", + "assignees_url": "https://api.github.com/repos/LAX18/ChatMaps/assignees{/user}", + "branches_url": "https://api.github.com/repos/LAX18/ChatMaps/branches{/branch}", + "tags_url": "https://api.github.com/repos/LAX18/ChatMaps/tags", + "blobs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/LAX18/ChatMaps/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/LAX18/ChatMaps/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/LAX18/ChatMaps/statuses/{sha}", + "languages_url": "https://api.github.com/repos/LAX18/ChatMaps/languages", + "stargazers_url": "https://api.github.com/repos/LAX18/ChatMaps/stargazers", + "contributors_url": "https://api.github.com/repos/LAX18/ChatMaps/contributors", + "subscribers_url": "https://api.github.com/repos/LAX18/ChatMaps/subscribers", + "subscription_url": "https://api.github.com/repos/LAX18/ChatMaps/subscription", + "commits_url": "https://api.github.com/repos/LAX18/ChatMaps/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/LAX18/ChatMaps/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/LAX18/ChatMaps/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/LAX18/ChatMaps/contents/{+path}", + "compare_url": "https://api.github.com/repos/LAX18/ChatMaps/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/LAX18/ChatMaps/merges", + "archive_url": "https://api.github.com/repos/LAX18/ChatMaps/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/LAX18/ChatMaps/downloads", + "issues_url": "https://api.github.com/repos/LAX18/ChatMaps/issues{/number}", + "pulls_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls{/number}", + "milestones_url": "https://api.github.com/repos/LAX18/ChatMaps/milestones{/number}", + "notifications_url": "https://api.github.com/repos/LAX18/ChatMaps/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/LAX18/ChatMaps/labels{/name}", + "releases_url": "https://api.github.com/repos/LAX18/ChatMaps/releases{/id}", + "deployments_url": "https://api.github.com/repos/LAX18/ChatMaps/deployments", + "created_at": "2024-02-18T02:13:20Z", + "updated_at": "2024-02-18T02:13:20Z", + "pushed_at": "2024-02-18T02:15:25Z", + "git_url": "git://github.com/LAX18/ChatMaps.git", + "ssh_url": "git@github.com:LAX18/ChatMaps.git", + "clone_url": "https://github.com/LAX18/ChatMaps.git", + "svn_url": "https://github.com/LAX18/ChatMaps", + "homepage": "", + "size": 82, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "LAX18", + "id": 34464552, + "node_id": "MDQ6VXNlcjM0NDY0NTUy", + "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/LAX18", + "html_url": "https://github.com/LAX18", + "followers_url": "https://api.github.com/users/LAX18/followers", + "following_url": "https://api.github.com/users/LAX18/following{/other_user}", + "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", + "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", + "organizations_url": "https://api.github.com/users/LAX18/orgs", + "repos_url": "https://api.github.com/users/LAX18/repos", + "events_url": "https://api.github.com/users/LAX18/events{/privacy}", + "received_events_url": "https://api.github.com/users/LAX18/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/backend/package-lock.json b/backend/server_update_hook/package-lock.json similarity index 100% rename from backend/package-lock.json rename to backend/server_update_hook/package-lock.json diff --git a/backend/package.json b/backend/server_update_hook/package.json similarity index 100% rename from backend/package.json rename to backend/server_update_hook/package.json -- 2.52.0 From a316c92ff9421f5ebc3a656f064497b3247235b4 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 02:39:27 +0000 Subject: [PATCH 09/14] Add conditional logic for PR closed, merged and to main --- backend/server_update_hook/api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/server_update_hook/api.js b/backend/server_update_hook/api.js index 47728c3..8a70e12 100644 --- a/backend/server_update_hook/api.js +++ b/backend/server_update_hook/api.js @@ -8,6 +8,9 @@ app.use(bodyParser.json()); // Recieves webhook from Github at https://chatmaps.nicholaspease.com/api/v1/deploy app.post("/api/v1/deploy", function (req, res) { console.log(req.body) + if (req.body.action == "closed" && req.body.pull_request.merged == true && req.body.pull_request.base.ref == "main") { + console.log("Closed & Merged") + } res.send("OK") }) -- 2.52.0 From cec4fac22fb0452b71b5bb7d51685eaf296fcec0 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 02:54:25 +0000 Subject: [PATCH 10/14] Add systemd file --- backend/server_update_hook/api.js | 1 - .../server_update_hook.service | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 backend/server_update_hook/server_update_hook.service diff --git a/backend/server_update_hook/api.js b/backend/server_update_hook/api.js index 8a70e12..81db8ed 100644 --- a/backend/server_update_hook/api.js +++ b/backend/server_update_hook/api.js @@ -7,7 +7,6 @@ app.use(bodyParser.json()); // Uses nodejs and express as "basic" backend server // Recieves webhook from Github at https://chatmaps.nicholaspease.com/api/v1/deploy app.post("/api/v1/deploy", function (req, res) { - console.log(req.body) if (req.body.action == "closed" && req.body.pull_request.merged == true && req.body.pull_request.base.ref == "main") { console.log("Closed & Merged") } diff --git a/backend/server_update_hook/server_update_hook.service b/backend/server_update_hook/server_update_hook.service new file mode 100644 index 0000000..b8f3528 --- /dev/null +++ b/backend/server_update_hook/server_update_hook.service @@ -0,0 +1,17 @@ +[Unit] +Description=ChatMaps Backend Server Updater / Restarter +After=network.target + +[Service] +Type=simple +User=root +Group=root +Restart=on-failure +RestartSec=10 +WorkingDirectory=/root/ChatMaps/backend/server_update_hook +ExecStartPre=/usr/bin/git pull +ExecStartPre=/usr/bin/npm install +ExecStart=/usr/bin/node api.js + +[Install] +WantedBy=multi-user.target \ No newline at end of file -- 2.52.0 From c10d496c57b1ee66648398d7b4072ec31b8b8cf9 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 03:03:35 +0000 Subject: [PATCH 11/14] Test logic for restart / update --- backend/server_update_hook/api.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/server_update_hook/api.js b/backend/server_update_hook/api.js index 81db8ed..e7e9d7d 100644 --- a/backend/server_update_hook/api.js +++ b/backend/server_update_hook/api.js @@ -1,6 +1,8 @@ const express = require("express") const app = express() const bodyParser = require("body-parser") +const { exec } = require("child_process") + app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); @@ -8,7 +10,7 @@ app.use(bodyParser.json()); // Recieves webhook from Github at https://chatmaps.nicholaspease.com/api/v1/deploy app.post("/api/v1/deploy", function (req, res) { if (req.body.action == "closed" && req.body.pull_request.merged == true && req.body.pull_request.base.ref == "main") { - console.log("Closed & Merged") + exec("systemctl restart server_update_hook.service", (error, stdout, stderr) => {}); } res.send("OK") }) -- 2.52.0 From f39b47b79029406144ad366b7a54b059ad0aae81 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 03:28:31 +0000 Subject: [PATCH 12/14] Add frontend systemd file --- backend/server_update_hook/api.js | 1 + backend/server_update_hook/example_PR.json | 521 ------------------ backend/systemd/frontend-next.service | 18 + .../server_update_hook.service | 0 4 files changed, 19 insertions(+), 521 deletions(-) delete mode 100644 backend/server_update_hook/example_PR.json create mode 100644 backend/systemd/frontend-next.service rename backend/{server_update_hook => systemd}/server_update_hook.service (100%) diff --git a/backend/server_update_hook/api.js b/backend/server_update_hook/api.js index e7e9d7d..e14ecfe 100644 --- a/backend/server_update_hook/api.js +++ b/backend/server_update_hook/api.js @@ -11,6 +11,7 @@ app.use(bodyParser.json()); app.post("/api/v1/deploy", function (req, res) { if (req.body.action == "closed" && req.body.pull_request.merged == true && req.body.pull_request.base.ref == "main") { exec("systemctl restart server_update_hook.service", (error, stdout, stderr) => {}); + exec("systemctl restart frontend-next.service", (error, stdout, stderr) => {}); } res.send("OK") }) diff --git a/backend/server_update_hook/example_PR.json b/backend/server_update_hook/example_PR.json deleted file mode 100644 index a8333c7..0000000 --- a/backend/server_update_hook/example_PR.json +++ /dev/null @@ -1,521 +0,0 @@ -{ - "action": "closed", - "number": 1, - "pull_request": { - "url": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1", - "id": 1731422439, - "node_id": "PR_kwDOLUDxO85nM2jn", - "html_url": "https://github.com/LAX18/ChatMaps/pull/1", - "diff_url": "https://github.com/LAX18/ChatMaps/pull/1.diff", - "patch_url": "https://github.com/LAX18/ChatMaps/pull/1.patch", - "issue_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/1", - "number": 1, - "state": "closed", - "locked": false, - "title": "Npease server update hook", - "user": { - "login": "LAX18", - "id": 34464552, - "node_id": "MDQ6VXNlcjM0NDY0NTUy", - "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/LAX18", - "html_url": "https://github.com/LAX18", - "followers_url": "https://api.github.com/users/LAX18/followers", - "following_url": "https://api.github.com/users/LAX18/following{/other_user}", - "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", - "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", - "organizations_url": "https://api.github.com/users/LAX18/orgs", - "repos_url": "https://api.github.com/users/LAX18/repos", - "events_url": "https://api.github.com/users/LAX18/events{/privacy}", - "received_events_url": "https://api.github.com/users/LAX18/received_events", - "type": "User", - "site_admin": false - }, - "body": null, - "created_at": "2024-02-18T02:14:48Z", - "updated_at": "2024-02-18T02:15:25Z", - "closed_at": "2024-02-18T02:15:25Z", - "merged_at": "2024-02-18T02:15:25Z", - "merge_commit_sha": "2e4fbaf6c30f82507ec7cff7895e57bc9de562b7", - "assignee": null, - "assignees": [ - - ], - "requested_reviewers": [ - - ], - "requested_teams": [ - - ], - "labels": [ - - ], - "milestone": null, - "draft": false, - "commits_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1/commits", - "review_comments_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1/comments", - "review_comment_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls/comments{/number}", - "comments_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/1/comments", - "statuses_url": "https://api.github.com/repos/LAX18/ChatMaps/statuses/fd82639658c788fb93c623166fdb7ddcbea7a384", - "head": { - "label": "LAX18:npease-server-update-hook", - "ref": "npease-server-update-hook", - "sha": "fd82639658c788fb93c623166fdb7ddcbea7a384", - "user": { - "login": "LAX18", - "id": 34464552, - "node_id": "MDQ6VXNlcjM0NDY0NTUy", - "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/LAX18", - "html_url": "https://github.com/LAX18", - "followers_url": "https://api.github.com/users/LAX18/followers", - "following_url": "https://api.github.com/users/LAX18/following{/other_user}", - "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", - "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", - "organizations_url": "https://api.github.com/users/LAX18/orgs", - "repos_url": "https://api.github.com/users/LAX18/repos", - "events_url": "https://api.github.com/users/LAX18/events{/privacy}", - "received_events_url": "https://api.github.com/users/LAX18/received_events", - "type": "User", - "site_admin": false - }, - "repo": { - "id": 759230779, - "node_id": "R_kgDOLUDxOw", - "name": "ChatMaps", - "full_name": "LAX18/ChatMaps", - "private": false, - "owner": { - "login": "LAX18", - "id": 34464552, - "node_id": "MDQ6VXNlcjM0NDY0NTUy", - "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/LAX18", - "html_url": "https://github.com/LAX18", - "followers_url": "https://api.github.com/users/LAX18/followers", - "following_url": "https://api.github.com/users/LAX18/following{/other_user}", - "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", - "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", - "organizations_url": "https://api.github.com/users/LAX18/orgs", - "repos_url": "https://api.github.com/users/LAX18/repos", - "events_url": "https://api.github.com/users/LAX18/events{/privacy}", - "received_events_url": "https://api.github.com/users/LAX18/received_events", - "type": "User", - "site_admin": false - }, - "html_url": "https://github.com/LAX18/ChatMaps", - "description": "Main repo for ChatMaps, COS420 Project", - "fork": true, - "url": "https://api.github.com/repos/LAX18/ChatMaps", - "forks_url": "https://api.github.com/repos/LAX18/ChatMaps/forks", - "keys_url": "https://api.github.com/repos/LAX18/ChatMaps/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/LAX18/ChatMaps/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/LAX18/ChatMaps/teams", - "hooks_url": "https://api.github.com/repos/LAX18/ChatMaps/hooks", - "issue_events_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/events{/number}", - "events_url": "https://api.github.com/repos/LAX18/ChatMaps/events", - "assignees_url": "https://api.github.com/repos/LAX18/ChatMaps/assignees{/user}", - "branches_url": "https://api.github.com/repos/LAX18/ChatMaps/branches{/branch}", - "tags_url": "https://api.github.com/repos/LAX18/ChatMaps/tags", - "blobs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/LAX18/ChatMaps/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/LAX18/ChatMaps/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/LAX18/ChatMaps/statuses/{sha}", - "languages_url": "https://api.github.com/repos/LAX18/ChatMaps/languages", - "stargazers_url": "https://api.github.com/repos/LAX18/ChatMaps/stargazers", - "contributors_url": "https://api.github.com/repos/LAX18/ChatMaps/contributors", - "subscribers_url": "https://api.github.com/repos/LAX18/ChatMaps/subscribers", - "subscription_url": "https://api.github.com/repos/LAX18/ChatMaps/subscription", - "commits_url": "https://api.github.com/repos/LAX18/ChatMaps/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/LAX18/ChatMaps/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/LAX18/ChatMaps/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/LAX18/ChatMaps/contents/{+path}", - "compare_url": "https://api.github.com/repos/LAX18/ChatMaps/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/LAX18/ChatMaps/merges", - "archive_url": "https://api.github.com/repos/LAX18/ChatMaps/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/LAX18/ChatMaps/downloads", - "issues_url": "https://api.github.com/repos/LAX18/ChatMaps/issues{/number}", - "pulls_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls{/number}", - "milestones_url": "https://api.github.com/repos/LAX18/ChatMaps/milestones{/number}", - "notifications_url": "https://api.github.com/repos/LAX18/ChatMaps/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/LAX18/ChatMaps/labels{/name}", - "releases_url": "https://api.github.com/repos/LAX18/ChatMaps/releases{/id}", - "deployments_url": "https://api.github.com/repos/LAX18/ChatMaps/deployments", - "created_at": "2024-02-18T02:13:20Z", - "updated_at": "2024-02-18T02:13:20Z", - "pushed_at": "2024-02-18T02:15:25Z", - "git_url": "git://github.com/LAX18/ChatMaps.git", - "ssh_url": "git@github.com:LAX18/ChatMaps.git", - "clone_url": "https://github.com/LAX18/ChatMaps.git", - "svn_url": "https://github.com/LAX18/ChatMaps", - "homepage": "", - "size": 82, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": false, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "has_discussions": false, - "forks_count": 0, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "allow_forking": true, - "is_template": false, - "web_commit_signoff_required": false, - "topics": [ - - ], - "visibility": "public", - "forks": 0, - "open_issues": 0, - "watchers": 0, - "default_branch": "main", - "allow_squash_merge": true, - "allow_merge_commit": true, - "allow_rebase_merge": true, - "allow_auto_merge": false, - "delete_branch_on_merge": false, - "allow_update_branch": false, - "use_squash_pr_title_as_default": false, - "squash_merge_commit_message": "COMMIT_MESSAGES", - "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", - "merge_commit_message": "PR_TITLE", - "merge_commit_title": "MERGE_MESSAGE" - } - }, - "base": { - "label": "LAX18:main", - "ref": "main", - "sha": "d05153ce683fc4c3a7f6fd0414d74f785c9e0fb6", - "user": { - "login": "LAX18", - "id": 34464552, - "node_id": "MDQ6VXNlcjM0NDY0NTUy", - "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/LAX18", - "html_url": "https://github.com/LAX18", - "followers_url": "https://api.github.com/users/LAX18/followers", - "following_url": "https://api.github.com/users/LAX18/following{/other_user}", - "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", - "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", - "organizations_url": "https://api.github.com/users/LAX18/orgs", - "repos_url": "https://api.github.com/users/LAX18/repos", - "events_url": "https://api.github.com/users/LAX18/events{/privacy}", - "received_events_url": "https://api.github.com/users/LAX18/received_events", - "type": "User", - "site_admin": false - }, - "repo": { - "id": 759230779, - "node_id": "R_kgDOLUDxOw", - "name": "ChatMaps", - "full_name": "LAX18/ChatMaps", - "private": false, - "owner": { - "login": "LAX18", - "id": 34464552, - "node_id": "MDQ6VXNlcjM0NDY0NTUy", - "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/LAX18", - "html_url": "https://github.com/LAX18", - "followers_url": "https://api.github.com/users/LAX18/followers", - "following_url": "https://api.github.com/users/LAX18/following{/other_user}", - "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", - "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", - "organizations_url": "https://api.github.com/users/LAX18/orgs", - "repos_url": "https://api.github.com/users/LAX18/repos", - "events_url": "https://api.github.com/users/LAX18/events{/privacy}", - "received_events_url": "https://api.github.com/users/LAX18/received_events", - "type": "User", - "site_admin": false - }, - "html_url": "https://github.com/LAX18/ChatMaps", - "description": "Main repo for ChatMaps, COS420 Project", - "fork": true, - "url": "https://api.github.com/repos/LAX18/ChatMaps", - "forks_url": "https://api.github.com/repos/LAX18/ChatMaps/forks", - "keys_url": "https://api.github.com/repos/LAX18/ChatMaps/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/LAX18/ChatMaps/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/LAX18/ChatMaps/teams", - "hooks_url": "https://api.github.com/repos/LAX18/ChatMaps/hooks", - "issue_events_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/events{/number}", - "events_url": "https://api.github.com/repos/LAX18/ChatMaps/events", - "assignees_url": "https://api.github.com/repos/LAX18/ChatMaps/assignees{/user}", - "branches_url": "https://api.github.com/repos/LAX18/ChatMaps/branches{/branch}", - "tags_url": "https://api.github.com/repos/LAX18/ChatMaps/tags", - "blobs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/LAX18/ChatMaps/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/LAX18/ChatMaps/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/LAX18/ChatMaps/statuses/{sha}", - "languages_url": "https://api.github.com/repos/LAX18/ChatMaps/languages", - "stargazers_url": "https://api.github.com/repos/LAX18/ChatMaps/stargazers", - "contributors_url": "https://api.github.com/repos/LAX18/ChatMaps/contributors", - "subscribers_url": "https://api.github.com/repos/LAX18/ChatMaps/subscribers", - "subscription_url": "https://api.github.com/repos/LAX18/ChatMaps/subscription", - "commits_url": "https://api.github.com/repos/LAX18/ChatMaps/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/LAX18/ChatMaps/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/LAX18/ChatMaps/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/LAX18/ChatMaps/contents/{+path}", - "compare_url": "https://api.github.com/repos/LAX18/ChatMaps/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/LAX18/ChatMaps/merges", - "archive_url": "https://api.github.com/repos/LAX18/ChatMaps/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/LAX18/ChatMaps/downloads", - "issues_url": "https://api.github.com/repos/LAX18/ChatMaps/issues{/number}", - "pulls_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls{/number}", - "milestones_url": "https://api.github.com/repos/LAX18/ChatMaps/milestones{/number}", - "notifications_url": "https://api.github.com/repos/LAX18/ChatMaps/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/LAX18/ChatMaps/labels{/name}", - "releases_url": "https://api.github.com/repos/LAX18/ChatMaps/releases{/id}", - "deployments_url": "https://api.github.com/repos/LAX18/ChatMaps/deployments", - "created_at": "2024-02-18T02:13:20Z", - "updated_at": "2024-02-18T02:13:20Z", - "pushed_at": "2024-02-18T02:15:25Z", - "git_url": "git://github.com/LAX18/ChatMaps.git", - "ssh_url": "git@github.com:LAX18/ChatMaps.git", - "clone_url": "https://github.com/LAX18/ChatMaps.git", - "svn_url": "https://github.com/LAX18/ChatMaps", - "homepage": "", - "size": 82, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": false, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "has_discussions": false, - "forks_count": 0, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "allow_forking": true, - "is_template": false, - "web_commit_signoff_required": false, - "topics": [ - - ], - "visibility": "public", - "forks": 0, - "open_issues": 0, - "watchers": 0, - "default_branch": "main", - "allow_squash_merge": true, - "allow_merge_commit": true, - "allow_rebase_merge": true, - "allow_auto_merge": false, - "delete_branch_on_merge": false, - "allow_update_branch": false, - "use_squash_pr_title_as_default": false, - "squash_merge_commit_message": "COMMIT_MESSAGES", - "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", - "merge_commit_message": "PR_TITLE", - "merge_commit_title": "MERGE_MESSAGE" - } - }, - "_links": { - "self": { - "href": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1" - }, - "html": { - "href": "https://github.com/LAX18/ChatMaps/pull/1" - }, - "issue": { - "href": "https://api.github.com/repos/LAX18/ChatMaps/issues/1" - }, - "comments": { - "href": "https://api.github.com/repos/LAX18/ChatMaps/issues/1/comments" - }, - "review_comments": { - "href": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1/comments" - }, - "review_comment": { - "href": "https://api.github.com/repos/LAX18/ChatMaps/pulls/comments{/number}" - }, - "commits": { - "href": "https://api.github.com/repos/LAX18/ChatMaps/pulls/1/commits" - }, - "statuses": { - "href": "https://api.github.com/repos/LAX18/ChatMaps/statuses/fd82639658c788fb93c623166fdb7ddcbea7a384" - } - }, - "author_association": "OWNER", - "auto_merge": null, - "active_lock_reason": null, - "merged": true, - "mergeable": null, - "rebaseable": null, - "mergeable_state": "unknown", - "merged_by": { - "login": "LAX18", - "id": 34464552, - "node_id": "MDQ6VXNlcjM0NDY0NTUy", - "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/LAX18", - "html_url": "https://github.com/LAX18", - "followers_url": "https://api.github.com/users/LAX18/followers", - "following_url": "https://api.github.com/users/LAX18/following{/other_user}", - "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", - "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", - "organizations_url": "https://api.github.com/users/LAX18/orgs", - "repos_url": "https://api.github.com/users/LAX18/repos", - "events_url": "https://api.github.com/users/LAX18/events{/privacy}", - "received_events_url": "https://api.github.com/users/LAX18/received_events", - "type": "User", - "site_admin": false - }, - "comments": 0, - "review_comments": 0, - "maintainer_can_modify": false, - "commits": 8, - "additions": 798, - "deletions": 39, - "changed_files": 21 - }, - "repository": { - "id": 759230779, - "node_id": "R_kgDOLUDxOw", - "name": "ChatMaps", - "full_name": "LAX18/ChatMaps", - "private": false, - "owner": { - "login": "LAX18", - "id": 34464552, - "node_id": "MDQ6VXNlcjM0NDY0NTUy", - "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/LAX18", - "html_url": "https://github.com/LAX18", - "followers_url": "https://api.github.com/users/LAX18/followers", - "following_url": "https://api.github.com/users/LAX18/following{/other_user}", - "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", - "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", - "organizations_url": "https://api.github.com/users/LAX18/orgs", - "repos_url": "https://api.github.com/users/LAX18/repos", - "events_url": "https://api.github.com/users/LAX18/events{/privacy}", - "received_events_url": "https://api.github.com/users/LAX18/received_events", - "type": "User", - "site_admin": false - }, - "html_url": "https://github.com/LAX18/ChatMaps", - "description": "Main repo for ChatMaps, COS420 Project", - "fork": true, - "url": "https://api.github.com/repos/LAX18/ChatMaps", - "forks_url": "https://api.github.com/repos/LAX18/ChatMaps/forks", - "keys_url": "https://api.github.com/repos/LAX18/ChatMaps/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/LAX18/ChatMaps/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/LAX18/ChatMaps/teams", - "hooks_url": "https://api.github.com/repos/LAX18/ChatMaps/hooks", - "issue_events_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/events{/number}", - "events_url": "https://api.github.com/repos/LAX18/ChatMaps/events", - "assignees_url": "https://api.github.com/repos/LAX18/ChatMaps/assignees{/user}", - "branches_url": "https://api.github.com/repos/LAX18/ChatMaps/branches{/branch}", - "tags_url": "https://api.github.com/repos/LAX18/ChatMaps/tags", - "blobs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/LAX18/ChatMaps/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/LAX18/ChatMaps/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/LAX18/ChatMaps/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/LAX18/ChatMaps/statuses/{sha}", - "languages_url": "https://api.github.com/repos/LAX18/ChatMaps/languages", - "stargazers_url": "https://api.github.com/repos/LAX18/ChatMaps/stargazers", - "contributors_url": "https://api.github.com/repos/LAX18/ChatMaps/contributors", - "subscribers_url": "https://api.github.com/repos/LAX18/ChatMaps/subscribers", - "subscription_url": "https://api.github.com/repos/LAX18/ChatMaps/subscription", - "commits_url": "https://api.github.com/repos/LAX18/ChatMaps/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/LAX18/ChatMaps/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/LAX18/ChatMaps/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/LAX18/ChatMaps/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/LAX18/ChatMaps/contents/{+path}", - "compare_url": "https://api.github.com/repos/LAX18/ChatMaps/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/LAX18/ChatMaps/merges", - "archive_url": "https://api.github.com/repos/LAX18/ChatMaps/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/LAX18/ChatMaps/downloads", - "issues_url": "https://api.github.com/repos/LAX18/ChatMaps/issues{/number}", - "pulls_url": "https://api.github.com/repos/LAX18/ChatMaps/pulls{/number}", - "milestones_url": "https://api.github.com/repos/LAX18/ChatMaps/milestones{/number}", - "notifications_url": "https://api.github.com/repos/LAX18/ChatMaps/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/LAX18/ChatMaps/labels{/name}", - "releases_url": "https://api.github.com/repos/LAX18/ChatMaps/releases{/id}", - "deployments_url": "https://api.github.com/repos/LAX18/ChatMaps/deployments", - "created_at": "2024-02-18T02:13:20Z", - "updated_at": "2024-02-18T02:13:20Z", - "pushed_at": "2024-02-18T02:15:25Z", - "git_url": "git://github.com/LAX18/ChatMaps.git", - "ssh_url": "git@github.com:LAX18/ChatMaps.git", - "clone_url": "https://github.com/LAX18/ChatMaps.git", - "svn_url": "https://github.com/LAX18/ChatMaps", - "homepage": "", - "size": 82, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": false, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "has_discussions": false, - "forks_count": 0, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "allow_forking": true, - "is_template": false, - "web_commit_signoff_required": false, - "topics": [ - - ], - "visibility": "public", - "forks": 0, - "open_issues": 0, - "watchers": 0, - "default_branch": "main" - }, - "sender": { - "login": "LAX18", - "id": 34464552, - "node_id": "MDQ6VXNlcjM0NDY0NTUy", - "avatar_url": "https://avatars.githubusercontent.com/u/34464552?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/LAX18", - "html_url": "https://github.com/LAX18", - "followers_url": "https://api.github.com/users/LAX18/followers", - "following_url": "https://api.github.com/users/LAX18/following{/other_user}", - "gists_url": "https://api.github.com/users/LAX18/gists{/gist_id}", - "starred_url": "https://api.github.com/users/LAX18/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/LAX18/subscriptions", - "organizations_url": "https://api.github.com/users/LAX18/orgs", - "repos_url": "https://api.github.com/users/LAX18/repos", - "events_url": "https://api.github.com/users/LAX18/events{/privacy}", - "received_events_url": "https://api.github.com/users/LAX18/received_events", - "type": "User", - "site_admin": false - } -} \ No newline at end of file diff --git a/backend/systemd/frontend-next.service b/backend/systemd/frontend-next.service new file mode 100644 index 0000000..081de77 --- /dev/null +++ b/backend/systemd/frontend-next.service @@ -0,0 +1,18 @@ +[Unit] +Description=ChatMaps Frontend Server +After=network.target + +[Service] +Type=simple +User=root +Group=root +Restart=on-failure +RestartSec=10 +WorkingDirectory=/root/ChatMaps/frontend-next +ExecStartPre=/usr/bin/git pull +ExecStartPre=/usr/bin/npm install +ExecStartPre=/usr/bin/npm run build +ExecStart=/usr/bin/npm run start + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/backend/server_update_hook/server_update_hook.service b/backend/systemd/server_update_hook.service similarity index 100% rename from backend/server_update_hook/server_update_hook.service rename to backend/systemd/server_update_hook.service -- 2.52.0 From 01f37ac46b61c58318c0f882aa60e968add8ff8b Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 04:03:49 +0000 Subject: [PATCH 13/14] Cleanup and Docs --- backend/server_update_hook/README.md | 16 ++++++++++++++++ backend/server_update_hook/api.js | 16 ++++++++++++---- backend/systemd/README.md | 8 ++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 backend/server_update_hook/README.md create mode 100644 backend/systemd/README.md diff --git a/backend/server_update_hook/README.md b/backend/server_update_hook/README.md new file mode 100644 index 0000000..6694ff3 --- /dev/null +++ b/backend/server_update_hook/README.md @@ -0,0 +1,16 @@ +## Server Update Hook +The purpose of this file is to enable automatic server updates when a pull request to the main branch succeeds. This is accomplished via a workflow sent from Github to the server which then reloads both itself and the frontend. + +## API Endpoints +Base Url: ```https://chatmaps.nicholaspease.com/api/v1/``` + +|Route|Method|Response Type|Use|Responses| +|-----|------|-------------|---|---------| +|```/``` |GET |Plain Text |Heartbeat|200 - "OK"| +|```/deploy```|POST|Plain Text |Server Update Trigger|200 - "OK" - Server Online / Updated + +## Files +|File|Purpose| +|----|-------| +|api.js|NodeJS API using Express| +|README.md|API Reference| \ No newline at end of file diff --git a/backend/server_update_hook/api.js b/backend/server_update_hook/api.js index e14ecfe..a043c95 100644 --- a/backend/server_update_hook/api.js +++ b/backend/server_update_hook/api.js @@ -1,17 +1,24 @@ +// Physical Server Update Hook +// Imports +// Requires express, body-parser, child_process const express = require("express") -const app = express() const bodyParser = require("body-parser") const { exec } = require("child_process") +// Start the express app and initialize +const app = express() app.use(bodyParser.urlencoded({ extended: false })); -app.use(bodyParser.json()); +app.use(bodyParser.json()); // This processes all the POST data as JSON // Uses nodejs and express as "basic" backend server -// Recieves webhook from Github at https://chatmaps.nicholaspease.com/api/v1/deploy +// Recieves webhook from Github at https://chatmaps.nicholaspease.com/ app.post("/api/v1/deploy", function (req, res) { + // Webhook returns all pull request actions + // Limit to "closed", "merged", and the target branch being "main" if (req.body.action == "closed" && req.body.pull_request.merged == true && req.body.pull_request.base.ref == "main") { - exec("systemctl restart server_update_hook.service", (error, stdout, stderr) => {}); + // (re)Start all the systemd files exec("systemctl restart frontend-next.service", (error, stdout, stderr) => {}); + exec("systemctl restart server_update_hook.service", (error, stdout, stderr) => {}); } res.send("OK") }) @@ -21,4 +28,5 @@ app.get('/api/v1', (req, res) => { res.send('OK') }) +// Server runs on port 8000, exposed on server at /api/v1 app.listen(8000) \ No newline at end of file diff --git a/backend/systemd/README.md b/backend/systemd/README.md new file mode 100644 index 0000000..19739b4 --- /dev/null +++ b/backend/systemd/README.md @@ -0,0 +1,8 @@ +## systemd (systemctl) Files +This folder contains all the files required by systemctl on the server for updating and running the backend/frontend. These are copied onto the server and placed in the ```/etc/systemd/system``` folder. + +## Files +|Filename|Connected Service| +|--------|-----------------| +|frontend-next.service|Folder: frontend-next| +|server_update_hook.service|Folder: backend/server_update_hook| \ No newline at end of file -- 2.52.0 From cbae67c36be6981efc8a738d3f0d1be8a8120f18 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Sun, 18 Feb 2024 04:06:45 +0000 Subject: [PATCH 14/14] Checkout main --- backend/systemd/frontend-next.service | 1 + backend/systemd/server_update_hook.service | 1 + 2 files changed, 2 insertions(+) diff --git a/backend/systemd/frontend-next.service b/backend/systemd/frontend-next.service index 081de77..f2185f5 100644 --- a/backend/systemd/frontend-next.service +++ b/backend/systemd/frontend-next.service @@ -10,6 +10,7 @@ Restart=on-failure RestartSec=10 WorkingDirectory=/root/ChatMaps/frontend-next ExecStartPre=/usr/bin/git pull +ExecStartPre=/usr/bin/git checkout main ExecStartPre=/usr/bin/npm install ExecStartPre=/usr/bin/npm run build ExecStart=/usr/bin/npm run start diff --git a/backend/systemd/server_update_hook.service b/backend/systemd/server_update_hook.service index b8f3528..cc21c96 100644 --- a/backend/systemd/server_update_hook.service +++ b/backend/systemd/server_update_hook.service @@ -10,6 +10,7 @@ Restart=on-failure RestartSec=10 WorkingDirectory=/root/ChatMaps/backend/server_update_hook ExecStartPre=/usr/bin/git pull +ExecStartPre=/usr/bin/git checkout main ExecStartPre=/usr/bin/npm install ExecStart=/usr/bin/node api.js -- 2.52.0