2021-02-16 21:55:50 +00:00
|
|
|
import express from 'express';
|
|
|
|
import * as http from 'http';
|
2021-04-20 07:40:15 +00:00
|
|
|
import * as dotenv from 'dotenv';
|
2021-08-20 11:26:38 +00:00
|
|
|
// 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/DHBWService.router';
|
2021-09-20 20:17:52 +00:00
|
|
|
import logger from './src/middleware/logger';
|
|
|
|
import {dhbwRaPlaChangesRouter} from './src/models/dhbw-rapla-changes/DHBWRaPlaChanges.router';
|
2021-10-07 11:06:51 +00:00
|
|
|
import {raPlaMiddlewareRouter} from './src/models/rapla-middleware/RaPlaMiddleware.router';
|
2021-11-11 10:52:27 +00:00
|
|
|
import {betterzonRouter} from './src/models/betterzon/Betterzon.router';
|
2021-04-20 07:40:15 +00:00
|
|
|
|
2021-09-29 10:55:08 +00:00
|
|
|
let cors = require('cors');
|
|
|
|
|
2021-04-20 07:40:15 +00:00
|
|
|
dotenv.config();
|
|
|
|
|
|
|
|
if (!process.env.PORT) {
|
2021-08-20 12:10:18 +00:00
|
|
|
logger.error('No port');
|
2021-04-20 07:40:15 +00:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2021-08-18 11:09:34 +00:00
|
|
|
const port: number = parseInt(process.env.PORT, 10);
|
2021-02-16 21:55:50 +00:00
|
|
|
|
|
|
|
const app: express.Application = express();
|
|
|
|
const server: http.Server = http.createServer(app);
|
|
|
|
|
|
|
|
// here we are adding middleware to parse all incoming requests as JSON
|
2021-08-20 11:26:38 +00:00
|
|
|
app.use(express.json());
|
2021-02-16 21:55:50 +00:00
|
|
|
|
2021-09-29 10:55:08 +00:00
|
|
|
// Use CORS
|
|
|
|
app.use(cors());
|
|
|
|
|
2021-08-18 11:09:34 +00:00
|
|
|
// Add routers
|
2021-08-18 12:02:59 +00:00
|
|
|
app.use('/dhbw-service', dhbwServiceRouter);
|
|
|
|
app.use('/twitch-highlight-marker', highlightMarkerRouter);
|
|
|
|
app.use('/partyplaner', partyPlanerRouter);
|
2021-09-20 20:17:52 +00:00
|
|
|
app.use('/raplachanges', dhbwRaPlaChangesRouter);
|
2021-10-07 11:06:51 +00:00
|
|
|
app.use('/rapla-middleware', raPlaMiddlewareRouter);
|
2021-11-11 10:52:27 +00:00
|
|
|
app.use('/betterzon', betterzonRouter);
|
2021-02-16 21:55:50 +00:00
|
|
|
|
|
|
|
// this is a simple route to make sure everything is working properly
|
|
|
|
app.get('/', (req: express.Request, res: express.Response) => {
|
2021-03-21 18:04:11 +00:00
|
|
|
res.status(200).send('Welcome to the Pluto Development REST API V2!');
|
2021-02-16 21:55:50 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
server.listen(port, () => {
|
2021-08-20 12:10:18 +00:00
|
|
|
logger.info('Server listening on Port ' + port);
|
2021-02-16 21:55:50 +00:00
|
|
|
});
|