Initial server blockout

This commit is contained in:
Alan O'Cull 2024-01-11 02:00:08 -05:00
parent eaa38cf6c1
commit a674d4f082
5 changed files with 32 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
node_modules/
config/secrets.json

View File

@ -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)

3
config/server.json Normal file
View File

@ -0,0 +1,3 @@
{
"port": 3001
}

View File

@ -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": {

22
src/index.js Normal file
View File

@ -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}`)
});