API-15: Error reference codes #14

Merged
Paddy merged 1 commits from API-15 into master 2021-08-29 14:49:33 +00:00
12 changed files with 111 additions and 28 deletions

View File

@ -4,6 +4,7 @@
import express, {Request, Response} from 'express';
import {generalInfoRouter} from './generalInfo/GeneralInfo.router';
import logger from '../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -17,7 +18,12 @@ dhbwServiceRouter.get('/', async (req: Request, res: Response) => {
try {
res.status(200).send('Pluto Development DHBW Service App API Endpoint');
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -3,6 +3,7 @@
*/
import express, {Request, Response} from 'express';
import logger from '../../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -13,8 +14,13 @@ generalInfoRouter.get('/', async (req: Request, res: Response) => {
try {
res.status(200).send('GET generalInfo v2.1');
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});
@ -22,7 +28,12 @@ generalInfoRouter.post('/', async (req: Request, res: Response) => {
try {
res.status(200).send('POST generalInfo v2.1');
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -10,6 +10,7 @@ import {eventRouter} from './event/Event.router';
import {friendshipRouter} from './friendship/Friendship.router';
import {inviteRouter} from './invite/Invite.router';
import {sessionRouter} from './session/Session.router';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -29,7 +30,12 @@ partyPlanerRouter.get('/', async (req: Request, res: Response) => {
try {
res.status(200).send('Pluto Development PartyPlaner API Endpoint V2');
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -5,6 +5,7 @@ import express, {Request, Response} from 'express';
import * as EventService from './event.service';
import * as UserService from '../user/user.service';
import logger from '../../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -13,6 +14,7 @@ export const eventRouter = express.Router();
eventRouter.get('/:isDevCall', async (req: Request, res: Response) => {
try {
throw new Error('Test');
let userId = (req.query.userId ?? '').toString();
let sessionId = (req.query.sessionId ?? '').toString();
let sessionKey = (req.query.sessionKey ?? '').toString();
@ -38,7 +40,12 @@ eventRouter.get('/:isDevCall', async (req: Request, res: Response) => {
res.status(200).send(data);
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -5,6 +5,7 @@ import express, {Request, Response} from 'express';
import * as FriendshipService from './friendship.service';
import * as UserService from '../user/user.service';
import logger from '../../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -38,7 +39,12 @@ friendshipRouter.get('/:isDevCall', async (req: Request, res: Response) => {
res.status(200).send(data);
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -5,6 +5,7 @@ import express, {Request, Response} from 'express';
import * as InviteService from './invite.service';
import * as UserService from '../user/user.service';
import logger from '../../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -38,7 +39,12 @@ inviteRouter.get('/:isDevCall', async (req: Request, res: Response) => {
res.status(200).send(data);
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -4,6 +4,7 @@
import express, {Request, Response} from 'express';
import * as UserService from '../user/user.service';
import logger from '../../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -52,7 +53,12 @@ loginRouter.post('/:isDevCall', async (req: Request, res: Response) => {
res.status(200).send(session);
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -4,6 +4,7 @@
import express, {Request, Response} from 'express';
import * as UserService from '../user/user.service';
import logger from '../../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -71,7 +72,12 @@ registerRouter.post('/:isDevCall', async (req: Request, res: Response) => {
res.status(201).send(session);
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -5,6 +5,7 @@ import express, {Request, Response} from 'express';
import * as SessionService from './session.service';
import * as UserService from '../user/user.service';
import logger from '../../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -38,7 +39,12 @@ sessionRouter.get('/:isDevCall', async (req: Request, res: Response) => {
res.status(200).send(data);
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -4,6 +4,7 @@
import express, {Request, Response} from 'express';
import * as UserService from './user.service';
import logger from '../../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -37,7 +38,12 @@ userRouter.get('/:isDevCall', async (req: Request, res: Response) => {
res.status(200).send(data);
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -4,6 +4,7 @@
import express, {Request, Response} from 'express';
import {addHighlightRouter} from './addHighlight/AddHighlight.router';
import logger from '../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -16,7 +17,12 @@ highlightMarkerRouter.get('/', async (req: Request, res: Response) => {
try {
res.status(200).send('Pluto Development Twitch Highlight Marker API Endpoint');
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});

View File

@ -4,6 +4,7 @@
import express, {Request, Response} from 'express';
import * as AddHighlightService from './addHighlights.service';
import logger from '../../../middleware/logger';
import {Guid} from 'guid-typescript';
/**
* Router Definition
@ -14,8 +15,13 @@ addHighlightRouter.get('/', (req: Request, res: Response) => {
try {
res.status(200).send('GET endpoint not defined.');
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});
@ -40,7 +46,12 @@ addHighlightRouter.post('/', (req: Request, res: Response) => {
res.status(200).send({'status': 'success', 'description': ''});
}
} catch (e) {
logger.error('Error handling a request: ' + e.message);
res.status(500).send({'message': 'Internal Server Error. Try again later.'});
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
});
}
});