API-10: Adding PartyPlaner register endpoint (#3)
Jenkins Production Deployment

- Also various other improvements

Co-authored-by: Patrick Müller <patrick@mueller-patrick.tech>
Reviewed-on: #3
Co-authored-by: Patrick Müller <patrick@plutodev.de>
Co-committed-by: Patrick Müller <patrick@plutodev.de>
This commit was merged in pull request #3.
This commit is contained in:
2021-08-20 11:26:38 +00:00
parent 7df8b5ad8e
commit 7265f92486
12 changed files with 651 additions and 1201 deletions
@@ -2,7 +2,7 @@
* Required External Modules and Interfaces
*/
import express, {Request, Response} from 'express';
import {addHighlightRouter} from "./addHighlight/AddHighlight.router";
import {addHighlightRouter} from './addHighlight/AddHighlight.router';
/**
* Router Definition
@@ -13,9 +13,9 @@ highlightMarkerRouter.use('/addHighlight', addHighlightRouter);
highlightMarkerRouter.get('/', async (req: Request, res: Response) => {
try {
res.status(200).send(`Pluto Development Twitch Highlight Marker API Endpoint`);
res.status(200).send('Pluto Development Twitch Highlight Marker API Endpoint');
} catch (e) {
console.log('Error handling a request: ' + e.message);
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
}
})
@@ -2,7 +2,7 @@
* Required External Modules and Interfaces
*/
import express, {Request, Response} from 'express';
import * as AddHighlightService from "./addHighlights.service";
import * as AddHighlightService from './addHighlights.service';
/**
* Router Definition
@@ -11,10 +11,10 @@ export const addHighlightRouter = express.Router();
addHighlightRouter.get('/', (req: Request, res: Response) => {
try {
res.status(200).send(`GET endpoint not defined.`);
res.status(200).send('GET endpoint not defined.');
} catch (e) {
console.log('Error handling a request: ' + e.message);
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
}
})
@@ -23,23 +23,23 @@ addHighlightRouter.post('/', (req: Request, res: Response) => {
// Check input params
const body = req.body;
if(body.access_key !== process.env.TWITCH_HIGHLIGHTS_ACCESS_KEY){
if (body.access_key !== process.env.TWITCH_HIGHLIGHTS_ACCESS_KEY) {
// Unauthorized, return error
res.type('application/json');
res.status(403).send('{"status": "error", "description": "Unauthorized."}');
} else if(!body.streamer || !body.stream_id || !body.stream_game || !body.timestamp || !body.description || !body.username){
res.status(403).send({'status': 'error', 'description': 'Unauthorized.'});
} else if (!body.streamer || !body.stream_id || !body.stream_game || !body.timestamp || !body.description || !body.username) {
// Missing params, return error
res.type('application/json');
res.status(400).send('{"status": "error", "description": "Missing parameters."}');
res.status(400).send({'status': 'error', 'description': 'Missing parameters.'});
} else {
// Everything fine, return success
AddHighlightService.createHighlightEntry(body);
res.type('application/json');
res.status(200).send('{"status": "success", "description": ""}');
res.status(200).send({'status': 'success', 'description': ''});
}
} catch (e) {
console.log('Error handling a request: ' + e.message);
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
}
})
@@ -13,7 +13,6 @@ const pool = mariadb.createPool({
export const createHighlightEntry = async (req_body: any) => {
let conn;
let price: any;
try {
conn = await pool.getConnection();