API-13: Adding PartyPlaner main endpoint #2

Merged
Paddy merged 1 commits from API-13 into master 2021-08-18 12:02:59 +00:00
8 changed files with 100 additions and 8 deletions

14
app.ts
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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