diff --git a/app.ts b/app.ts index 1459c33..fece404 100644 --- a/app.ts +++ b/app.ts @@ -12,11 +12,10 @@ if (!process.env.PORT) { const port: number = parseInt(process.env.PORT, 10); -// DHBW Service -import {generalInfoRouter} from "./src/models/dhbw-service/GeneralInfo.router"; - -// Twitch Highlight Marker -import {addHighlightRouter} from "./src/models/twitch-highlight-marker/AddHighlight.router"; +// Router imports +import {partyPlanerRouter} from "./src/models/partyplaner/PartyPlaner.router"; +import {highlightMarkerRouter} from "./src/models/twitch-highlight-marker/HighlightMarker.router"; +import { dhbwServiceRouter } from './src/models/dhbw-service/DHBWServiceRouter'; const app: express.Application = express(); const server: http.Server = http.createServer(app); @@ -25,8 +24,9 @@ const server: http.Server = http.createServer(app); app.use(bodyparser.json()); // Add routers -app.use('/dhbw-service/generalInfo', generalInfoRouter); -app.use('/twitch-highlight-marker/addHighlight', addHighlightRouter); +app.use('/dhbw-service', dhbwServiceRouter); +app.use('/twitch-highlight-marker', highlightMarkerRouter); +app.use('/partyplaner', partyPlanerRouter); // this is a simple route to make sure everything is working properly app.get('/', (req: express.Request, res: express.Response) => { diff --git a/src/models/dhbw-service/DHBWServiceRouter.ts b/src/models/dhbw-service/DHBWServiceRouter.ts new file mode 100644 index 0000000..058c9ed --- /dev/null +++ b/src/models/dhbw-service/DHBWServiceRouter.ts @@ -0,0 +1,22 @@ +/** + * Required External Modules and Interfaces + */ +import express, {Request, Response} from 'express'; +import {generalInfoRouter} from "./generalInfo/GeneralInfo.router"; + +/** + * Router Definition + */ +export const dhbwServiceRouter = express.Router(); + +// Sub-Endpoints +dhbwServiceRouter.use('/generalInfo', generalInfoRouter); + +generalInfoRouter.get('/', async (req: Request, res: Response) => { + try { + res.status(200).send(`Pluto Development DHBW Service App 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.'})); + } +}) diff --git a/src/models/dhbw-service/GeneralInfo.router.ts b/src/models/dhbw-service/generalInfo/GeneralInfo.router.ts similarity index 93% rename from src/models/dhbw-service/GeneralInfo.router.ts rename to src/models/dhbw-service/generalInfo/GeneralInfo.router.ts index aeb4169..e416e21 100644 --- a/src/models/dhbw-service/GeneralInfo.router.ts +++ b/src/models/dhbw-service/generalInfo/GeneralInfo.router.ts @@ -19,7 +19,7 @@ generalInfoRouter.get('/', async (req: Request, res: Response) => { generalInfoRouter.post('/', async (req: Request, res: Response) => { try { - res.status(200).send(`GET generalInfo v2.1`); + res.status(200).send(`POST generalInfo v2.1`); } catch (e) { console.log('Error handling a request: ' + e.message); res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'})); diff --git a/src/models/partyplaner/PartyPlaner.router.ts b/src/models/partyplaner/PartyPlaner.router.ts new file mode 100644 index 0000000..611b814 --- /dev/null +++ b/src/models/partyplaner/PartyPlaner.router.ts @@ -0,0 +1,22 @@ +/** + * Required External Modules and Interfaces + */ +import express, {Request, Response} from 'express'; +import {dataRouter} from "./data/Data.router"; + +/** + * Router Definition + */ +export const partyPlanerRouter = express.Router(); + +// Sub-Endpoints +partyPlanerRouter.use('/data', dataRouter); + +partyPlanerRouter.get('/', async (req: Request, res: Response) => { + try { + res.status(200).send(`Pluto Development PartyPlaner API Endpoint V2`); + } catch (e) { + console.log('Error handling a request: ' + e.message); + res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'})); + } +}) diff --git a/src/models/partyplaner/data/Data.router.ts b/src/models/partyplaner/data/Data.router.ts new file mode 100644 index 0000000..20c30ce --- /dev/null +++ b/src/models/partyplaner/data/Data.router.ts @@ -0,0 +1,27 @@ +/** + * Required External Modules and Interfaces + */ +import express, {Request, Response} from 'express'; + +/** + * Router Definition + */ +export const dataRouter = express.Router(); + +dataRouter.get('/', async (req: Request, res: Response) => { + try { + res.status(200).send(`GET data`); + } catch (e) { + console.log('Error handling a request: ' + e.message); + res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'})); + } +}) + +dataRouter.post('/', async (req: Request, res: Response) => { + try { + res.status(200).send(`POST data`); + } catch (e) { + console.log('Error handling a request: ' + e.message); + res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'})); + } +}) diff --git a/src/models/twitch-highlight-marker/HighlightMarker.router.ts b/src/models/twitch-highlight-marker/HighlightMarker.router.ts new file mode 100644 index 0000000..b016121 --- /dev/null +++ b/src/models/twitch-highlight-marker/HighlightMarker.router.ts @@ -0,0 +1,21 @@ +/** + * Required External Modules and Interfaces + */ +import express, {Request, Response} from 'express'; +import {addHighlightRouter} from "./addHighlight/AddHighlight.router"; + +/** + * Router Definition + */ +export const highlightMarkerRouter = express.Router(); + +highlightMarkerRouter.use('/addHighlight', addHighlightRouter); + +highlightMarkerRouter.get('/', async (req: Request, res: Response) => { + try { + 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.'})); + } +}) diff --git a/src/models/twitch-highlight-marker/AddHighlight.router.ts b/src/models/twitch-highlight-marker/addHighlight/AddHighlight.router.ts similarity index 100% rename from src/models/twitch-highlight-marker/AddHighlight.router.ts rename to src/models/twitch-highlight-marker/addHighlight/AddHighlight.router.ts diff --git a/src/models/twitch-highlight-marker/addHighlights.service.ts b/src/models/twitch-highlight-marker/addHighlight/addHighlights.service.ts similarity index 100% rename from src/models/twitch-highlight-marker/addHighlights.service.ts rename to src/models/twitch-highlight-marker/addHighlight/addHighlights.service.ts