Front : create class to connect, send and receive message

- Create environment class
 - Create Connexion class to connect and save data
 - Refactor back api
This commit is contained in:
gparant 2020-04-05 20:57:14 +02:00
parent b4f77ba51a
commit 7e08e7f133
8 changed files with 374 additions and 5 deletions

View file

@ -2,7 +2,7 @@
import {IoSocketController} from "./Controller/IoSocketController"; //TODO fix import by "_Controller/..."
import {AuthenticateController} from "./Controller/AuthenticateController"; //TODO fix import by "_Controller/..."
import express from "express";
import {Application} from 'express';
import {Application, Request, Response} from 'express';
import bodyParser = require('body-parser');
import * as http from "http";
@ -28,6 +28,11 @@ class App {
private config(): void {
this.app.use(bodyParser.json());
this.app.use(bodyParser.urlencoded({extended: false}));
this.app.use(function (req: Request, res: Response, next) {
res.header("Access-Control-Allow-Origin", "*"); // update to match the domain you will make the request from
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
}
}

View file

@ -22,7 +22,7 @@ export class AuthenticateController{
}
//TODO check user email for The Coding Machine game
let token = Jwt.sign({email: param.email, roomId: ROOM}, SECRET_KEY, {expiresIn: '24h'});
return res.status(OK).send({token: token});
return res.status(OK).send({token: token, roomId: ROOM});
});
}
}

View file

@ -6,7 +6,7 @@ export class Point implements PointInterface{
y: number;
constructor(x : number, y : number) {
if(!x || !y){
if(x === null || y === null){
throw Error("position x and y cannot be null");
}
this.x = x;