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' )
6
12
dotenv . config ( ) ;
7
13
8
- const port : number = 3000 ;
9
- const app : express . Application = express ( ) ;
14
+ const port = 3000 ;
15
+ const app = express ( ) ;
10
16
const cors = require ( 'cors' ) ;
11
17
const cookieParser = require ( 'cookie-parser' ) ;
12
18
@@ -33,15 +39,15 @@ const io = require('socket.io')(server, {
33
39
// https://stackoverflow.com/questions/47249009/nodejs-socket-io-in-a-router-page
34
40
app . set ( 'socketio' , io ) ;
35
41
36
- io . on ( 'connection' , ( client : $TSFixMe ) => {
42
+ io . on ( 'connection' , ( client ) => {
37
43
console . log ( 'established websocket connection' ) ;
38
44
39
- client . on ( 'message' , ( message : string ) => {
45
+ client . on ( 'message' , ( message ) => {
40
46
console . log ( 'message received: ' , message ) ;
41
47
} ) ;
42
48
} ) ;
43
49
44
- app . get ( '/' , ( _ , res : Response ) => res . send ( 'Hello World!' ) ) ;
50
+ app . get ( '/' , ( _ , res ) => res . send ( 'Hello World!' ) ) ;
45
51
46
52
app . use ( express . static ( path . resolve ( __dirname , '../../build' ) ) ) ;
47
53
app . use ( express . urlencoded ( { extended : true } ) ) ;
@@ -50,7 +56,7 @@ app.use(express.json());
50
56
app . use ( cors ( { origin : 'http://localhost:8080' } ) ) ;
51
57
52
58
/** @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 ) => {
54
60
console . log ( 'Server Is On!' ) ;
55
61
// ngrok
56
62
// .connect({
@@ -64,29 +70,29 @@ app.post('/webhookServer', (req: Request, res: Response) => {
64
70
} ) ;
65
71
66
72
/** @todo webhook is not working on swell */
67
- app . delete ( '/webhookServer' , ( req : Request , res : Response ) => {
73
+ app . delete ( '/webhookServer' , ( req , res ) => {
68
74
console . log ( 'Server Is Off!' ) ;
69
75
ngrok . kill ( ) ;
70
76
return res . status ( 200 ) . json ( 'the server has been deleted' ) ;
71
77
} ) ;
72
78
73
- app . post ( '/webhook' , ( req : Request , res : Response ) => {
79
+ app . post ( '/webhook' , ( req , res ) => {
74
80
const data = { headers : req . headers , body : req . body } ;
75
81
io . emit ( 'response' , data ) ;
76
82
return res . status ( 200 ) . json ( req . body ) ;
77
83
} ) ;
78
84
79
- app . get ( '/api/import' , ( _ : Request , res : Response ) => {
85
+ app . get ( '/api/import' , ( _ , res ) => {
80
86
return res . status ( 200 ) . send ( res . locals . swellFile ) ;
81
87
} ) ;
82
88
83
89
//inital error handler, needs work
84
- app . use ( '*' , ( _ : Request , res : Response ) => {
90
+ app . use ( '*' , ( _ , res ) => {
85
91
res . status ( 404 ) . send ( 'Not Found' ) ;
86
92
} ) ;
87
93
88
94
// Global Handler, needs work
89
- app . use ( ( err : any , _1 : Request , res : Response , _2 : NextFunction ) => {
95
+ app . use ( ( err , _1 , res , _2 ) => {
90
96
const defaultErr = {
91
97
log : 'Express error handler caught unknown middleware error' ,
92
98
status : 500 ,
0 commit comments