Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Voting
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dennis Willers
Voting
Commits
58ce6b0e
Commit
58ce6b0e
authored
Aug 20, 2021
by
Dennis Willers
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix GetMapp Error if Map is not yet init
parent
6d94378e
Pipeline
#420
passed with stages
in 2 minutes and 40 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
events.js
events.js
+15
-12
socket.js
socket.js
+2
-2
No files found.
events.js
View file @
58ce6b0e
...
@@ -144,14 +144,14 @@ function createRouter(db) {
...
@@ -144,14 +144,14 @@ function createRouter(db) {
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
error in getMapInfo
'
});
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
error in getMapInfo
'
});
}
else
{
}
else
{
if
(
results
.
length
===
1
)
{
if
(
results
.
length
===
1
)
{
cons
t
average
=
results
[
0
].
average
;
le
t
average
=
results
[
0
].
average
;
cons
t
votes
=
results
[
0
].
votes
;
le
t
votes
=
results
[
0
].
votes
;
if
(
average
!==
null
&&
votes
!==
null
)
{
if
(
!
average
)
average
=
0
;
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
200
).
json
({
votes
:
votes
,
average
:
average
,
vote
:
vote
})
;
if
(
!
votes
)
votes
=
0
;
return
;
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
200
).
json
({
votes
:
votes
,
average
:
average
,
vote
:
vote
})
;
}
return
;
}
}
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
error
in getMapInfo
'
});
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
unexpected result
in getMapInfo
'
});
}
}
});
});
}
else
{
}
else
{
...
@@ -172,15 +172,18 @@ function createRouter(db) {
...
@@ -172,15 +172,18 @@ function createRouter(db) {
console
.
log
(
error
);
console
.
log
(
error
);
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
error in getVote
'
});
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
error in getVote
'
});
}
else
{
}
else
{
if
(
results
.
length
===
1
)
{
if
(
results
.
length
<
2
)
{
const
vote
=
results
[
0
].
vote
;
let
vote
=
-
1
;
if
(
vote
!==
null
)
{
if
(
results
.
length
===
1
)
{
vote
=
results
[
0
].
vote
;
}
if
(
vote
)
{
req
.
body
.
vote
=
vote
;
req
.
body
.
vote
=
vote
;
getMapInfo
(
req
,
res
);
getMapInfo
(
req
,
res
);
return
;
return
;
}
}
}
}
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
error
in getVote
'
});
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
unexpected result
in getVote
'
});
}
}
});
});
}
else
{
}
else
{
...
@@ -196,7 +199,7 @@ function createRouter(db) {
...
@@ -196,7 +199,7 @@ function createRouter(db) {
router
.
get
(
'
/test
'
,
[
test
]);
router
.
get
(
'
/test
'
,
[
test
]);
router
.
post
(
'
/setVote
'
,
[
hasMap
,
hasVote
,
getMapInfo
]);
router
.
post
(
'
/setVote
'
,
[
hasMap
,
hasVote
,
getMapInfo
]);
router
.
post
(
'
/getMapInfo
'
,
[
getVote
]);
router
.
post
(
'
/getMapInfo
'
,
[
hasMap
,
getVote
]);
return
router
;
return
router
;
}
}
...
...
socket.js
View file @
58ce6b0e
...
@@ -234,9 +234,9 @@ client.on('data',function(data){
...
@@ -234,9 +234,9 @@ client.on('data',function(data){
// u can also => write the below code in seperate js file
// u can also => write the below code in seperate js file
// open new node instance => and run it...
// open new node instance => and run it...
// 87.78.129.86
// 87.78.129.86
| localhost
const
testClient
=
net
.
connect
({
host
:
'
localhost
'
,
port
:
3000
},
()
=>
{
const
testClient
=
net
.
connect
({
host
:
'
87.78.129.86
'
,
port
:
3201
},
()
=>
{
console
.
log
(
'
connected to server!
'
);
console
.
log
(
'
connected to server!
'
);
testClient
.
write
(
'
Hello World Client!
\r\n
'
);
testClient
.
write
(
'
Hello World Client!
\r\n
'
);
//test(testClient);
//test(testClient);
...
...
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