fixed stable state
This commit is contained in:
+14
-5
@@ -13,15 +13,22 @@ import cors from 'cors';
|
||||
import getLineRoutes from './routes/line';
|
||||
import getSearchRoutes from './routes/search';
|
||||
import getUserRoutes from './routes/user';
|
||||
import morgan from 'morgan';
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(morgan('combined'));
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
|
||||
app.use((req: Request, res: Response, next: NextFunction) => {
|
||||
console.log('Time: ', new Date());
|
||||
next();
|
||||
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
|
||||
console.error(err);
|
||||
next(err);
|
||||
});
|
||||
|
||||
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
|
||||
res.status(500);
|
||||
res.json(new NirvanaResponse(undefined, err, err.message));
|
||||
});
|
||||
|
||||
app.get('/', (req: Request, res: Response) => {
|
||||
@@ -36,8 +43,10 @@ app.use('/api/user', getUserRoutes());
|
||||
app.use('/api/search', getSearchRoutes());
|
||||
app.use('/api/lines', getLineRoutes());
|
||||
|
||||
const PORT = 5000;
|
||||
const server = app.listen(PORT, () => console.log('express running'));
|
||||
const PORT = process.env.PORT || 8080;
|
||||
const server = app.listen(PORT, () =>
|
||||
console.log(`express running on port | ${PORT} in host machine`),
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const io = require('socket.io')(server, {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { NextFunction, Request, Response } from 'express';
|
||||
|
||||
import environmentVariables from '../config/config';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const jwt = require('jsonwebtoken');
|
||||
|
||||
// used by specific routes that need to authentication
|
||||
@@ -14,7 +15,7 @@ export const authCheck = async (req: Request, res: Response, next: NextFunction)
|
||||
}
|
||||
|
||||
// verify jwt token with our api secret
|
||||
var decoded: JwtClaims = jwt.verify(authorization, environmentVariables.JWT_TOKEN_SECRET);
|
||||
const decoded: JwtClaims = jwt.verify(authorization, environmentVariables.JWT_TOKEN_SECRET);
|
||||
|
||||
res.locals.userInfo = decoded;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
"port": "4000",
|
||||
"loggerPort": "9000",
|
||||
"mainConfig": "./webpack.main.config.js",
|
||||
"devContentSecurityPolicy": "connect-src 'self' http://localhost:5000 ws://localhost:5000 https://api.quotable.io/random 'unsafe-eval'",
|
||||
"devContentSecurityPolicy": "default-src * self blob: data: gap:; style-src * self 'unsafe-inline' blob: data: gap:; script-src * 'self' 'unsafe-eval' 'unsafe-inline' blob: data: gap:; object-src * 'self' blob: data: gap:; img-src * self 'unsafe-inline' blob: data: gap:; connect-src self * 'unsafe-inline' blob: data: gap:; frame-src * self blob: data: gap:;",
|
||||
"renderer": {
|
||||
"config": "./webpack.renderer.config.js",
|
||||
"entryPoints": [
|
||||
|
||||
@@ -6,14 +6,14 @@ import { Line } from '@nirvana/core/models/line.model';
|
||||
import LoginResponse from '@nirvana/core/responses/login.response';
|
||||
import MasterLineData from '@nirvana/core/models/masterLineData.model';
|
||||
import NirvanaResponse from '@nirvana/core/responses/nirvanaResponse';
|
||||
import UpdateLineMemberState from '@nirvana/core/requests/updateLineMemberState.request';
|
||||
import { User } from '@nirvana/core/models';
|
||||
import UserDetailsResponse from '@nirvana/core/responses/userDetails.response';
|
||||
import UserSearchResponse from '@nirvana/core/responses/userSearch.response';
|
||||
import UpdateLineMemberState from '@nirvana/core/requests/updateLineMemberState.request';
|
||||
|
||||
// export const localHost = process.env.REACT_APP_API_DOMAIN;
|
||||
|
||||
export const localHost = 'http://localhost:5000/api';
|
||||
export const localHost = 'http://localhost:8080/api';
|
||||
|
||||
export default class NirvanaApi {
|
||||
// auth token from google that our backend will use
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React, { useState, useEffect, useContext, useCallback } from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
import { io, Socket } from 'socket.io-client';
|
||||
import useAuth from './AuthProvider';
|
||||
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
||||
import { Socket, io } from 'socket.io-client';
|
||||
|
||||
import FlowState from '../tree/protected/FlowState';
|
||||
import toast from 'react-hot-toast';
|
||||
import useAuth from './AuthProvider';
|
||||
|
||||
interface ISocketProvider {
|
||||
$ws: Socket;
|
||||
@@ -46,7 +47,7 @@ export function SocketProvider({ children }: { children: React.ReactNode }) {
|
||||
return;
|
||||
}
|
||||
|
||||
const socketConnection = io('http://localhost:5000', {
|
||||
const socketConnection = io('http://localhost:8080', {
|
||||
query: { token: jwtToken },
|
||||
transports: ['websocket'],
|
||||
upgrade: false,
|
||||
|
||||
Reference in New Issue
Block a user