API-13: Adding PartyPlaner main endpoint (#2)
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Jenkins Production Deployment
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	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 is contained in:
		
							parent
							
								
									5ef4fdb4e2
								
							
						
					
					
						commit
						7df8b5ad8e
					
				
							
								
								
									
										14
									
								
								app.ts
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								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) => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										22
									
								
								src/models/dhbw-service/DHBWServiceRouter.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/models/dhbw-service/DHBWServiceRouter.ts
									
									
									
									
									
										Normal 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.'}));
 | 
			
		||||
    }
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			@ -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.'}));
 | 
			
		||||
							
								
								
									
										22
									
								
								src/models/partyplaner/PartyPlaner.router.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/models/partyplaner/PartyPlaner.router.ts
									
									
									
									
									
										Normal 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.'}));
 | 
			
		||||
    }
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										27
									
								
								src/models/partyplaner/data/Data.router.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/models/partyplaner/data/Data.router.ts
									
									
									
									
									
										Normal 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.'}));
 | 
			
		||||
    }
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										21
									
								
								src/models/twitch-highlight-marker/HighlightMarker.router.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/models/twitch-highlight-marker/HighlightMarker.router.ts
									
									
									
									
									
										Normal 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.'}));
 | 
			
		||||
    }
 | 
			
		||||
})
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user