Merge pull request #6 from louis-antoine-etsmtl/fix-sockets
merge to fix sockets
2
client/.dockerignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
**/node_modules
|
||||||
|
.env
|
||||||
2
client/.env.example
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
VITE_BACKEND_URL=localhost:4400
|
||||||
|
VITE_AZURE_BACKEND_URL=localhost:4400
|
||||||
18
client/.eslintrc.cjs
Normal 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
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/prettierrc",
|
||||||
|
"tabWidth": 4,
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 100,
|
||||||
|
"trailingComma": "none"
|
||||||
|
}
|
||||||
21
client/LICENSE
Normal 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.
|
||||||
13
client/pull_request_template.md
Normal 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.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3,4 +3,5 @@ const ENV_VARIABLES = {
|
||||||
MODE: 'production',
|
MODE: 'production',
|
||||||
VITE_BACKEND_URL: import.meta.env.VITE_BACKEND_URL || ""
|
VITE_BACKEND_URL: import.meta.env.VITE_BACKEND_URL || ""
|
||||||
};
|
};
|
||||||
|
|
||||||
export { ENV_VARIABLES };
|
export { ENV_VARIABLES };
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ const JoinRoom: React.FC = () => {
|
||||||
|
|
||||||
const handleCreateSocket = () => {
|
const handleCreateSocket = () => {
|
||||||
const socket = webSocketService.connect(ENV_VARIABLES.VITE_BACKEND_URL);
|
const socket = webSocketService.connect(ENV_VARIABLES.VITE_BACKEND_URL);
|
||||||
|
|
||||||
socket.on('join-success', () => {
|
socket.on('join-success', () => {
|
||||||
setIsWaitingForTeacher(true);
|
setIsWaitingForTeacher(true);
|
||||||
setIsConnecting(false);
|
setIsConnecting(false);
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ const ManageRoom: React.FC = () => {
|
||||||
const createWebSocketRoom = () => {
|
const createWebSocketRoom = () => {
|
||||||
setConnectingError('');
|
setConnectingError('');
|
||||||
const socket = webSocketService.connect(ENV_VARIABLES.VITE_BACKEND_URL);
|
const socket = webSocketService.connect(ENV_VARIABLES.VITE_BACKEND_URL);
|
||||||
|
|
||||||
console.log(socket);
|
console.log(socket);
|
||||||
socket.on('connect', () => {
|
socket.on('connect', () => {
|
||||||
webSocketService.createRoom();
|
webSocketService.createRoom();
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ export default defineConfig({
|
||||||
strictPort: true
|
strictPort: true
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 8080,
|
port: 5173,
|
||||||
strictPort: true,
|
strictPort: true,
|
||||||
host: true,
|
host: true,
|
||||||
origin: "http://0.0.0.0:8080",
|
origin: "http://0.0.0.0:5173",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,11 @@ server {
|
||||||
location /socket.io {
|
location /socket.io {
|
||||||
rewrite /backend/(.*) /$1 break;
|
rewrite /backend/(.*) /$1 break;
|
||||||
proxy_pass http://backend;
|
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 / {
|
location / {
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 152 KiB |
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
2
server/.dockerignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
**/node_modules
|
||||||
|
.env
|
||||||
14
server/.env.example
Normal 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!
|
||||||
|
|
@ -8,6 +8,6 @@ RUN npm install
|
||||||
|
|
||||||
COPY ./ .
|
COPY ./ .
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 4400
|
||||||
|
|
||||||
CMD ["npm", "run", "start"]
|
CMD ["npm", "run", "start"]
|
||||||
21
server/LICENSE
Normal 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.
|
||||||
|
|
@ -4,7 +4,7 @@ const http = require("http");
|
||||||
const dotenv = require('dotenv')
|
const dotenv = require('dotenv')
|
||||||
|
|
||||||
// Import Sockets
|
// Import Sockets
|
||||||
const { setupWebsocket } = require("./socket/socket.js");
|
const { setupWebsocket } = require("./socket/socket");
|
||||||
const { Server } = require("socket.io");
|
const { Server } = require("socket.io");
|
||||||
|
|
||||||
//import routers
|
//import routers
|
||||||
|
|
@ -54,7 +54,7 @@ app.use(errorHandler)
|
||||||
// Start server
|
// Start server
|
||||||
async function start() {
|
async function start() {
|
||||||
|
|
||||||
const port = process.env.PORT || 3000;
|
const port = process.env.PORT || 4400;
|
||||||
|
|
||||||
// Check DB connection
|
// Check DB connection
|
||||||
await db.connect()
|
await db.connect()
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
const model = require('../models/folders.js');
|
const model = require('../models/folders.js');
|
||||||
|
|
||||||
const AppError = require('../middleware/AppError.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 {
|
class FoldersController {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const model = require('../models/images.js');
|
const model = require('../models/images.js');
|
||||||
|
|
||||||
const AppError = require('../middleware/AppError.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 {
|
class ImagesController {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ const folderModel = require('../models/folders.js');
|
||||||
const emailer = require('../config/email.js');
|
const emailer = require('../config/email.js');
|
||||||
|
|
||||||
const AppError = require('../middleware/AppError.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 {
|
class QuizController {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ const model = require('../models/users.js');
|
||||||
const jwt = require('../middleware/jwtToken.js');
|
const jwt = require('../middleware/jwtToken.js');
|
||||||
|
|
||||||
const AppError = require('../middleware/AppError.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 {
|
class UsersController {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const jwt = require('jsonwebtoken')
|
const jwt = require('jsonwebtoken')
|
||||||
const dotenv = require('dotenv')
|
const dotenv = require('dotenv')
|
||||||
const AppError = require('./AppError.js');
|
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();
|
dotenv.config();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
const db = require('../config/db.js');
|
const db = require('../config/db.js');
|
||||||
const bcrypt = require('bcrypt');
|
const bcrypt = require('bcrypt');
|
||||||
const AppError = require('../middleware/AppError.js');
|
const AppError = require('../middleware/AppError.js');
|
||||||
const { USER_ALREADY_EXISTS } = require('../constants/errorCodes.js');
|
const { USER_ALREADY_EXISTS } = require('../constants/errorCodes');
|
||||||
const Folders = require('./folders.js');
|
const Folders = require('../models/folders.js');
|
||||||
|
|
||||||
class Users {
|
class Users {
|
||||||
|
|
||||||
|
|
|
||||||