API-13: Adding PartyPlaner main endpoint (#2)
Jenkins Production Deployment

- Also did some refactoring for cleaner code

Co-authored-by: Patrick Müller <patrick@mueller-patrick.tech>
Reviewed-on: #2
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 #2.
This commit is contained in:
2021-08-18 12:02:59 +00:00
parent 5ef4fdb4e2
commit 7df8b5ad8e
8 changed files with 100 additions and 8 deletions
@@ -0,0 +1,39 @@
import * as dotenv from 'dotenv';
dotenv.config();
const mariadb = require('mariadb');
const pool = mariadb.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.TWITCH_HIGHLIGHTS_DATABASE,
connectionLimit: 5
});
export const createHighlightEntry = async (req_body: any) => {
let conn;
let price: any;
try {
conn = await pool.getConnection();
const streamers = await conn.query('SELECT streamer_id FROM streamers WHERE username = ?', req_body.streamer);
let streamer_id: number = -1;
for (let row in streamers) {
if (row !== 'meta') {
streamer_id = streamers[row].streamer_id;
}
}
const params = [streamer_id, req_body.stream_id, req_body.description, req_body.timestamp, req_body.username, req_body.stream_game];
const rows = await conn.query('INSERT INTO highlights (streamer_id, stream_id, description, stream_timestamp, issuing_user, game) VALUES (?, ?, ?, ?, ?, ?)', params);
} catch (err) {
throw err;
} finally {
if (conn) {
conn.end();
}
}
}