Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Romain DUPONT
Online Chess
Commits
86497de8
Commit
86497de8
authored
Feb 19, 2019
by
Erwan Bousse
Browse files
Merge branch 'master' of gitlab.univ-nantes.fr:naomod/software-development-course/onlineChess
parents
4d52721e
482a5a43
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main.ts
View file @
86497de8
...
@@ -19,6 +19,7 @@ class HttpServer {
...
@@ -19,6 +19,7 @@ class HttpServer {
public
onStart
():
void
{
public
onStart
():
void
{
let
chessboard
:
Chessboard
=
createInitialChessboard
();
let
chessboard
:
Chessboard
=
createInitialChessboard
();
let
app
:
express
.
Application
=
express
();
let
app
:
express
.
Application
=
express
();
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
use
(
express
.
static
(
PUBLIC_DIR
));
app
.
use
(
express
.
static
(
PUBLIC_DIR
));
...
@@ -29,7 +30,7 @@ class HttpServer {
...
@@ -29,7 +30,7 @@ class HttpServer {
});
});
app
.
get
(
'
/
'
,
(
req
:
express
.
Request
,
res
:
express
.
Response
)
=>
{
app
.
get
(
'
/
'
,
(
req
:
express
.
Request
,
res
:
express
.
Response
)
=>
{
res
.
render
(
'
index
'
,
{
error
:
"
Erreur
"
});
res
.
render
(
'
index
'
,
{
error
:
null
});
})
})
app
.
get
(
"
/status.js
"
,
(
req
:
express
.
Request
,
res
:
express
.
Response
)
=>
{
app
.
get
(
"
/status.js
"
,
(
req
:
express
.
Request
,
res
:
express
.
Response
)
=>
{
...
@@ -38,9 +39,9 @@ class HttpServer {
...
@@ -38,9 +39,9 @@ class HttpServer {
app
.
post
(
"
/
"
,
(
req
:
express
.
Request
,
res
:
express
.
Response
)
=>
{
app
.
post
(
"
/
"
,
(
req
:
express
.
Request
,
res
:
express
.
Response
)
=>
{
let
unparsedMove
:
string
=
req
.
body
.
move
;
let
unparsedMove
:
string
=
req
.
body
.
move
;
chessboard
=
processMove
(
chessboard
,
unparsedMove
);
let
didPerfom
:
boolean
=
processMove
(
chessboard
,
unparsedMove
);
//res.redirect("/");
let
message
:
string
=
didPerfom
?
""
:
"
Invalid movement!
"
res
.
render
(
'
index
'
,
{
error
:
null
});
res
.
render
(
'
index
'
,
{
error
:
message
});
});
});
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment