1- import path from 'path' ;
2- import express , { Request , Response , NextFunction } from 'express' ;
3- import ngrok from 'ngrok' ;
4- import dotenv from 'dotenv' ;
5- import { $TSFixMe } from '../types' ;
1+ // import path from 'path';
2+
3+ // import express, { Request, Response, NextFunction } from 'express';
4+ // import ngrok from 'ngrok';
5+ // import dotenv from 'dotenv';
6+ // import { $TSFixMe } from '../types';
7+
8+ const path = require ( 'path' )
9+ const express = require ( 'express' )
10+ const ngrok = require ( 'ngrok' )
11+ const dotenv = require ( 'dotenv' )
612dotenv . config ( ) ;
713
8- const port : number = 3000 ;
9- const app : express . Application = express ( ) ;
14+ const port = 3000 ;
15+ const app = express ( ) ;
1016const cors = require ( 'cors' ) ;
1117const cookieParser = require ( 'cookie-parser' ) ;
1218
@@ -33,15 +39,15 @@ const io = require('socket.io')(server, {
3339// https://stackoverflow.com/questions/47249009/nodejs-socket-io-in-a-router-page
3440app . set ( 'socketio' , io ) ;
3541
36- io . on ( 'connection' , ( client : $TSFixMe ) => {
42+ io . on ( 'connection' , ( client ) => {
3743 console . log ( 'established websocket connection' ) ;
3844
39- client . on ( 'message' , ( message : string ) => {
45+ client . on ( 'message' , ( message ) => {
4046 console . log ( 'message received: ' , message ) ;
4147 } ) ;
4248} ) ;
4349
44- app . get ( '/' , ( _ , res : Response ) => res . send ( 'Hello World!' ) ) ;
50+ app . get ( '/' , ( _ , res ) => res . send ( 'Hello World!' ) ) ;
4551
4652app . use ( express . static ( path . resolve ( __dirname , '../../build' ) ) ) ;
4753app . use ( express . urlencoded ( { extended : true } ) ) ;
@@ -50,7 +56,7 @@ app.use(express.json());
5056app . use ( cors ( { origin : 'http://localhost:8080' } ) ) ;
5157
5258/** @todo previous groups decided to use ngrok to add live collaboration session but could not finished */
53- app . post ( '/webhookServer' , ( req : Request , res : Response ) => {
59+ app . post ( '/webhookServer' , ( req , res ) => {
5460 console . log ( 'Server Is On!' ) ;
5561 // ngrok
5662 // .connect({
@@ -64,29 +70,29 @@ app.post('/webhookServer', (req: Request, res: Response) => {
6470} ) ;
6571
6672/** @todo webhook is not working on swell */
67- app . delete ( '/webhookServer' , ( req : Request , res : Response ) => {
73+ app . delete ( '/webhookServer' , ( req , res ) => {
6874 console . log ( 'Server Is Off!' ) ;
6975 ngrok . kill ( ) ;
7076 return res . status ( 200 ) . json ( 'the server has been deleted' ) ;
7177} ) ;
7278
73- app . post ( '/webhook' , ( req : Request , res : Response ) => {
79+ app . post ( '/webhook' , ( req , res ) => {
7480 const data = { headers : req . headers , body : req . body } ;
7581 io . emit ( 'response' , data ) ;
7682 return res . status ( 200 ) . json ( req . body ) ;
7783} ) ;
7884
79- app . get ( '/api/import' , ( _ : Request , res : Response ) => {
85+ app . get ( '/api/import' , ( _ , res ) => {
8086 return res . status ( 200 ) . send ( res . locals . swellFile ) ;
8187} ) ;
8288
8389//inital error handler, needs work
84- app . use ( '*' , ( _ : Request , res : Response ) => {
90+ app . use ( '*' , ( _ , res ) => {
8591 res . status ( 404 ) . send ( 'Not Found' ) ;
8692} ) ;
8793
8894// Global Handler, needs work
89- app . use ( ( err : any , _1 : Request , res : Response , _2 : NextFunction ) => {
95+ app . use ( ( err , _1 , res , _2 ) => {
9096 const defaultErr = {
9197 log : 'Express error handler caught unknown middleware error' ,
9298 status : 500 ,
0 commit comments