From a674d4f0823c72e373c1df46dfec925dc8905c86 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 11 Jan 2024 02:00:08 -0500 Subject: [PATCH] Initial server blockout --- .gitignore | 1 + README.md | 5 +++++ config/server.json | 3 +++ package.json | 1 + src/index.js | 22 ++++++++++++++++++++++ 5 files changed, 32 insertions(+) create mode 100644 config/server.json create mode 100644 src/index.js diff --git a/.gitignore b/.gitignore index c2658d7..9f6c94b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +config/secrets.json diff --git a/README.md b/README.md index 9624152..8b59b84 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,8 @@ Automation tool to reduce pain while taking CGT365 - [Atlassian NPM module](https://bitbucket.org/atlassian/atlassian-connect-express/src/master/) +- [Jira REST API](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#about) +- API Tokens can be generated [here](https://id.atlassian.com/manage-profile/security/api-tokens) + - Tips on [managing API tokens](https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/) +- [PatternPacker](https://git.alanocull.com/alan/pattern-packer/src/branch/master/src/server/server.ts) uses some basic express hosting +- Jira REST API docs for [issues](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-group-issues) diff --git a/config/server.json b/config/server.json new file mode 100644 index 0000000..adc1d2a --- /dev/null +++ b/config/server.json @@ -0,0 +1,3 @@ +{ + "port": 3001 +} \ No newline at end of file diff --git a/package.json b/package.json index bc89815..4b793dd 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Tool for basic mirroring issues, tasks, and commits between Gitea and Jira", "main": "index.js", "scripts": { + "server": "node ./src/index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..333d9d6 --- /dev/null +++ b/src/index.js @@ -0,0 +1,22 @@ +const fs = require('fs'); +const express = require('express'); +const { append } = require('express/lib/response'); + +// LOAD CONFIGURATION +const CONFIG_DIRECTORY = `${process.cwd()}/config/`; +/** @var {Object} */ +const CONFIG = JSON.parse(fs.readFileSync(`${CONFIG_DIRECTORY}server.json`, 'utf-8')); +const SECRETS = JSON.parse(fs.readFileSync(`${CONFIG_DIRECTORY}secrets.json`, 'utf-8')); +const PORT = CONFIG['port']; + +// INITIALIZE EXPRESS +const app = express(); + +app.get('/', (req, res) => { + console.log("Got request ", req.url); + res.send({'data':'nice'}); +}) + +app.listen(PORT, () => { + console.log(`Server is running on localhost:${PORT}, working in ${CONFIG_DIRECTORY}`) +});