Merge pull request #6 from louis-antoine-etsmtl/fix-sockets

merge to fix sockets
This commit is contained in:
louis-antoine-etsmtl 2024-04-05 20:11:51 -04:00 committed by GitHub
commit 409b209479
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 121 additions and 13 deletions

2
client/.dockerignore Normal file
View file

@ -0,0 +1,2 @@
**/node_modules
.env

2
client/.env.example Normal file
View file

@ -0,0 +1,2 @@
VITE_BACKEND_URL=localhost:4400
VITE_AZURE_BACKEND_URL=localhost:4400

18
client/.eslintrc.cjs Normal file
View file

@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}

7
client/.prettierrc.json Normal file
View file

@ -0,0 +1,7 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"tabWidth": 4,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}

21
client/LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 ETS-PFE004-Plateforme-sondage-minitest
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,13 @@
## PULL REQUEST
## Description
## Link to the ticket
## Checklist before requesting a review
- [ ] I have performed a self-review of my code
- [ ] If it is a core feature, I have added thorough tests.
- [ ] Do we need to implement analytics?
- [ ] Will this be part of a product update? If yes, please write one phrase about this update.

View file

@ -3,4 +3,5 @@ const ENV_VARIABLES = {
MODE: 'production',
VITE_BACKEND_URL: import.meta.env.VITE_BACKEND_URL || ""
};
export { ENV_VARIABLES };

View file

@ -35,6 +35,7 @@ const JoinRoom: React.FC = () => {
const handleCreateSocket = () => {
const socket = webSocketService.connect(ENV_VARIABLES.VITE_BACKEND_URL);
socket.on('join-success', () => {
setIsWaitingForTeacher(true);
setIsConnecting(false);

View file

@ -82,6 +82,7 @@ const ManageRoom: React.FC = () => {
const createWebSocketRoom = () => {
setConnectingError('');
const socket = webSocketService.connect(ENV_VARIABLES.VITE_BACKEND_URL);
console.log(socket);
socket.on('connect', () => {
webSocketService.createRoom();

View file

@ -14,9 +14,9 @@ export default defineConfig({
strictPort: true
},
server: {
port: 8080,
port: 5173,
strictPort: true,
host: true,
origin: "http://0.0.0.0:8080",
origin: "http://0.0.0.0:5173",
},
});

View file

@ -17,6 +17,11 @@ server {
location /socket.io {
rewrite /backend/(.*) /$1 break;
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_hide_header 'Access-Control-Allow-Origin';
}
location / {

2
server/.dockerignore Normal file
View file

@ -0,0 +1,2 @@
**/node_modules
.env

14
server/.env.example Normal file
View file

@ -0,0 +1,14 @@
# Config serveur
PORT=4400
# Config BD
MONGO_URI=mongodb://localhost:27017
MONGO_DATABASE=evaluetonsavoir
# Config emails
EMAIL_SERVICE=gmail
SENDER_EMAIL=infoevaluetonsavoir@gmail.com
EMAIL_PSW='vvml wmfr dkzb vjzb'
# JSON Web Token
JWT_SECRET=TOKEN!

View file

@ -8,6 +8,6 @@ RUN npm install
COPY ./ .
EXPOSE 3000
EXPOSE 4400
CMD ["npm", "run", "start"]

21
server/LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 ETS-PFE004-Plateforme-sondage-minitest
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -4,7 +4,7 @@ const http = require("http");
const dotenv = require('dotenv')
// Import Sockets
const { setupWebsocket } = require("./socket/socket.js");
const { setupWebsocket } = require("./socket/socket");
const { Server } = require("socket.io");
//import routers
@ -54,7 +54,7 @@ app.use(errorHandler)
// Start server
async function start() {
const port = process.env.PORT || 3000;
const port = process.env.PORT || 4400;
// Check DB connection
await db.connect()

View file

@ -2,7 +2,7 @@
const model = require('../models/folders.js');
const AppError = require('../middleware/AppError.js');
const { MISSING_REQUIRED_PARAMETER, NOT_IMPLEMENTED, FOLDER_NOT_FOUND, FOLDER_ALREADY_EXISTS, GETTING_FOLDER_ERROR, DELETE_FOLDER_ERROR, UPDATE_FOLDER_ERROR, MOVING_FOLDER_ERROR, DUPLICATE_FOLDER_ERROR, COPY_FOLDER_ERROR } = require('../constants/errorCodes.js');
const { MISSING_REQUIRED_PARAMETER, NOT_IMPLEMENTED, FOLDER_NOT_FOUND, FOLDER_ALREADY_EXISTS, GETTING_FOLDER_ERROR, DELETE_FOLDER_ERROR, UPDATE_FOLDER_ERROR, MOVING_FOLDER_ERROR, DUPLICATE_FOLDER_ERROR, COPY_FOLDER_ERROR } = require('../constants/errorCodes');
class FoldersController {

View file

@ -1,7 +1,7 @@
const model = require('../models/images.js');
const AppError = require('../middleware/AppError.js');
const { MISSING_REQUIRED_PARAMETER, IMAGE_NOT_FOUND } = require('../constants/errorCodes.js');
const { MISSING_REQUIRED_PARAMETER, IMAGE_NOT_FOUND } = require('../constants/errorCodes');
class ImagesController {

View file

@ -3,7 +3,7 @@ const folderModel = require('../models/folders.js');
const emailer = require('../config/email.js');
const AppError = require('../middleware/AppError.js');
const { MISSING_REQUIRED_PARAMETER, NOT_IMPLEMENTED, QUIZ_NOT_FOUND, FOLDER_NOT_FOUND, QUIZ_ALREADY_EXISTS, GETTING_QUIZ_ERROR, DELETE_QUIZ_ERROR, UPDATE_QUIZ_ERROR, MOVING_QUIZ_ERROR, DUPLICATE_QUIZ_ERROR, COPY_QUIZ_ERROR } = require('../constants/errorCodes.js');
const { MISSING_REQUIRED_PARAMETER, NOT_IMPLEMENTED, QUIZ_NOT_FOUND, FOLDER_NOT_FOUND, QUIZ_ALREADY_EXISTS, GETTING_QUIZ_ERROR, DELETE_QUIZ_ERROR, UPDATE_QUIZ_ERROR, MOVING_QUIZ_ERROR, DUPLICATE_QUIZ_ERROR, COPY_QUIZ_ERROR } = require('../constants/errorCodes');
class QuizController {

View file

@ -3,7 +3,7 @@ const model = require('../models/users.js');
const jwt = require('../middleware/jwtToken.js');
const AppError = require('../middleware/AppError.js');
const { MISSING_REQUIRED_PARAMETER, LOGIN_CREDENTIALS_ERROR, GENERATE_PASSWORD_ERROR, UPDATE_PASSWORD_ERROR, DELETE_USER_ERROR } = require('../constants/errorCodes.js');
const { MISSING_REQUIRED_PARAMETER, LOGIN_CREDENTIALS_ERROR, GENERATE_PASSWORD_ERROR, UPDATE_PASSWORD_ERROR, DELETE_USER_ERROR } = require('../constants/errorCodes');
class UsersController {

View file

@ -1,7 +1,7 @@
const jwt = require('jsonwebtoken')
const dotenv = require('dotenv')
const AppError = require('./AppError.js');
const { UNAUTHORIZED_NO_TOKEN_GIVEN, UNAUTHORIZED_INVALID_TOKEN } = require('../constants/errorCodes.js');
const { UNAUTHORIZED_NO_TOKEN_GIVEN, UNAUTHORIZED_INVALID_TOKEN } = require('../constants/errorCodes');
dotenv.config();

View file

@ -2,8 +2,8 @@
const db = require('../config/db.js');
const bcrypt = require('bcrypt');
const AppError = require('../middleware/AppError.js');
const { USER_ALREADY_EXISTS } = require('../constants/errorCodes.js');
const Folders = require('./folders.js');
const { USER_ALREADY_EXISTS } = require('../constants/errorCodes');
const Folders = require('../models/folders.js');
class Users {