Initial commit

This commit is contained in:
2022-12-24 14:32:13 +01:00
commit 3996e37682
17 changed files with 10283 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import * as dotenv from 'dotenv';
const mariadb = require('mariadb');
dotenv.config();
export namespace NachklangCalendarDB {
const pool = mariadb.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.CALENDAR_DB,
connectionLimit: 5
});
export const getConnection = async () => {
return pool.getConnection();
};
}
+26
View File
@@ -0,0 +1,26 @@
/**
* Required External Modules and Interfaces
*/
import express, {Request, Response} from 'express';
import {Guid} from 'guid-typescript';
import logger from '../../middleware/logger';
/**
* Router Definition
*/
export const calendarRouter = express.Router();
calendarRouter.get('/', async (req: Request, res: Response) => {
try {
res.status(200).send('Nachklang e.V. Calendar API Endpoint');
} catch (e: any) {
let errorGuid = Guid.create().toString();
logger.error('Error handling a request: ' + e.message, {reference: errorGuid});
res.status(500).send({
'status': 'PROCESSING_ERROR',
'message': 'Internal Server Error. Try again later.',
'reference': errorGuid
});
}
});