Last commit ?
This commit is contained in:
parent
75060a0997
commit
34a5f703ea
9 changed files with 61 additions and 26 deletions
21
README.md
21
README.md
|
|
@ -1,5 +1,26 @@
|
||||||
**Projet Chat**
|
**Projet Chat**
|
||||||
|
|
||||||
|
**Instruction de lancement du Chat**
|
||||||
|
- `docker compose up`
|
||||||
|
- Puis se connecter en local sur `http://localhost:4200`
|
||||||
|
- Le client ne se connecte pas pour l'instant. Mais le serveur démarre enfin, problème entre toutes les images docker,
|
||||||
|
seul l'image des bases de données MongoDB et l'image du service-authentication marche. Les deux autres services
|
||||||
|
ne marchent pas en image docker à cause du socket pour je ne sais quelle raison.
|
||||||
|
|
||||||
|
Pour lancer le projet sans image docker, il est obligatoire de lancer plusieurs terminals pour le frontend et pour chaque
|
||||||
|
serveurs et avoir des images dockers mongodb.
|
||||||
|
A savoir:
|
||||||
|
- Terminal Frontend dans le dossier frontend : `ng serve`
|
||||||
|
- Terminal service-authentication dans le dossier service-authentication : `node server.js`
|
||||||
|
- Terminal service-message dans le dossier service-message : `node server.js`
|
||||||
|
- Terminal service-privateroom dans le dossier service-privateroom : `node server.js`
|
||||||
|
- Puis se connecter en local sur `http://localhost:4200`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**Instruction du professeur**
|
||||||
Le but du projet est de fournir un service de chat rudimentaire :
|
Le but du projet est de fournir un service de chat rudimentaire :
|
||||||
- Une interface utilisateur en web
|
- Une interface utilisateur en web
|
||||||
- Les utilisateurs peuvent s'enregistrer/se connecter/se déconnecter/changer leur mot de passe
|
- Les utilisateurs peuvent s'enregistrer/se connecter/se déconnecter/changer leur mot de passe
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ app.use(bodyParser.urlencoded({extended:true}));
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
app.use(cors({origin: 'http://127.0.0.1:4200', credentials: true}));
|
app.use(cors({origin: 'http://localhost:4200', credentials: true}));
|
||||||
|
|
||||||
const mongoConnect = require('./mongodbConnect');
|
const mongoConnect = require('./mongodbConnect');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,20 @@ function getSession (req, callback) {
|
||||||
url: 'http://127.0.0.1:3000/verify:token',
|
url: 'http://127.0.0.1:3000/verify:token',
|
||||||
body: 'sessionid='+req.headers.cookie.replace('SESSIONID=','')
|
body: 'sessionid='+req.headers.cookie.replace('SESSIONID=','')
|
||||||
},function (error, response, body) {
|
},function (error, response, body) {
|
||||||
const bodyJson = JSON.parse(body);
|
console.log("body ; getSession auth message :",body);
|
||||||
if (bodyJson && bodyJson.status && bodyJson.data) {
|
if(typeof body !== 'undefined'){
|
||||||
if (bodyJson.status === 'ok') {
|
const bodyJson = JSON.parse(body);
|
||||||
return callback(bodyJson.data.token);
|
if (bodyJson && bodyJson.status && bodyJson.data) {
|
||||||
} else {
|
if (bodyJson.status === 'ok') {
|
||||||
return callback(bodyJson.data.reason);
|
return callback(bodyJson.data.token);
|
||||||
|
} else {
|
||||||
|
return callback(bodyJson.data.reason);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
return callback('Error');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return callback(undefined);
|
return callback(undefined);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ const app = express();
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
const io = new Server(server, {
|
const io = new Server(server, {
|
||||||
cors: {
|
cors: {
|
||||||
origin: "http://127.0.0.1:4200",
|
origin: "http://localhost:4200",
|
||||||
methods: ["GET", "POST"],
|
methods: ["GET", "POST"],
|
||||||
credentials: true
|
credentials: true
|
||||||
}
|
}
|
||||||
|
|
@ -19,7 +19,7 @@ const io = new Server(server, {
|
||||||
const port = process.env.PORT || 3001;
|
const port = process.env.PORT || 3001;
|
||||||
|
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
app.use(cors({origin: 'http://127.0.0.1:4200', credentials: true}));
|
app.use(cors({origin: 'http://localhost:4200', credentials: true}));
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -114,6 +114,6 @@ io.on('connection',socket => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(port, '0.0.0.0',() => {
|
server.listen(port,'0.0.0.0', () => {
|
||||||
console.log (`listening on port ${port}`);
|
console.log (`listening on port ${port}`);
|
||||||
});
|
});
|
||||||
|
|
@ -7,14 +7,20 @@ function getSession (req, callback) {
|
||||||
url: 'http://127.0.0.1:3000/verify:token',
|
url: 'http://127.0.0.1:3000/verify:token',
|
||||||
body: 'sessionid='+req.headers.cookie.replace('SESSIONID=','')
|
body: 'sessionid='+req.headers.cookie.replace('SESSIONID=','')
|
||||||
},function (error, response, body) {
|
},function (error, response, body) {
|
||||||
const bodyJson = JSON.parse(body);
|
console.log("body ; getSession auth private :",body);
|
||||||
if (bodyJson && bodyJson.status && bodyJson.data) {
|
if(typeof body !== 'undefined'){
|
||||||
if (bodyJson.status === 'ok') {
|
const bodyJson = JSON.parse(body);
|
||||||
return callback(bodyJson.data.token);
|
if (bodyJson && bodyJson.status && bodyJson.data) {
|
||||||
} else {
|
if (bodyJson.status === 'ok') {
|
||||||
return callback(bodyJson.data.reason);
|
return callback(bodyJson.data.token);
|
||||||
|
} else {
|
||||||
|
return callback(bodyJson.data.reason);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
return callback('Error');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return callback(undefined);
|
return callback(undefined);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const { Server } = require("socket.io");
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
const io = new Server(server, {
|
const io = new Server(server, {
|
||||||
cors: {
|
cors: {
|
||||||
origin: "http://127.0.0.1:4200",
|
origin: "http://localhost:4200",
|
||||||
methods: ["GET", "POST"],
|
methods: ["GET", "POST"],
|
||||||
credentials: true
|
credentials: true
|
||||||
}
|
}
|
||||||
|
|
@ -20,7 +20,7 @@ const cookieParser = require('cookie-parser');
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
|
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
app.use(cors({origin: 'http://127.0.0.1:4200', credentials: true}));
|
app.use(cors({origin: 'http://localhost:4200', credentials: true}));
|
||||||
|
|
||||||
const auth = require("./auth");
|
const auth = require("./auth");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,11 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- service-authentication
|
- service-authentication
|
||||||
- service-message
|
- service-message
|
||||||
|
- service-privateroom
|
||||||
links:
|
links:
|
||||||
- service-authentication
|
- service-authentication
|
||||||
- service-message
|
- service-message
|
||||||
|
- service-privateroom
|
||||||
|
|
||||||
service-authentication:
|
service-authentication:
|
||||||
container_name: service-authentication
|
container_name: service-authentication
|
||||||
|
|
@ -42,7 +44,7 @@ services:
|
||||||
- backend/service-message
|
- backend/service-message
|
||||||
- backend/service-message/node_modules
|
- backend/service-message/node_modules
|
||||||
ports:
|
ports:
|
||||||
- 3001:3000
|
- 3001:3001
|
||||||
depends_on:
|
depends_on:
|
||||||
- mongodb-message
|
- mongodb-message
|
||||||
links:
|
links:
|
||||||
|
|
@ -58,7 +60,7 @@ services:
|
||||||
- backend/service-privateroom
|
- backend/service-privateroom
|
||||||
- backend/service-privateroom/node_modules
|
- backend/service-privateroom/node_modules
|
||||||
ports:
|
ports:
|
||||||
- 3002:3000
|
- 3002:3002
|
||||||
depends_on:
|
depends_on:
|
||||||
- mongodb-privateroom
|
- mongodb-privateroom
|
||||||
links:
|
links:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: true,
|
production: true,
|
||||||
urlCL: 'http://127.0.0.1:3000',
|
urlCL: 'http://localhost:3000',
|
||||||
urlCG: 'http://127.0.0.1:3001',
|
urlCG: 'http://localhost:3001',
|
||||||
urlCPR: 'http://127.0.0.1:3002'
|
urlCPR: 'http://localhost:3002'
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
urlCL: 'http://127.0.0.1:3000',
|
urlCL: 'http://localhost:3000',
|
||||||
urlCG: 'http://127.0.0.1:3001',
|
urlCG: 'http://localhost:3001',
|
||||||
urlCPR: 'http://127.0.0.1:3002'
|
urlCPR: 'http://localhost:3002'
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Reference in a new issue