Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Tabu-Middleware
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
Tabu-Middleware
Commits
00542a98
Commit
00542a98
authored
Dec 29, 2020
by
Dennis Willers
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort Out isSession into function
parent
368c5391
Pipeline
#299
failed with stages
in 1 minute and 45 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
20 deletions
+24
-20
events.js
events.js
+24
-20
No files found.
events.js
View file @
00542a98
...
@@ -3,6 +3,29 @@ const express = require('express');
...
@@ -3,6 +3,29 @@ const express = require('express');
function
createRouter
(
db
)
{
function
createRouter
(
db
)
{
const
router
=
express
.
Router
();
const
router
=
express
.
Router
();
function
isSession
(
req
,
res
)
{
const
spielname
=
req
.
body
.
spielname
;
if
(
spielname
.
match
(
/^
[
0-9a-zA-Z
]
+$/
)
!=
null
)
{
db
.
query
(
'
SELECT SessionName FROM Session WHERE SessionName =
\'
'
+
spielname
+
'
\'
;
'
,
(
error
,
results
)
=>
{
if
(
error
)
{
console
.
log
(
error
);
return
res
.
status
(
500
).
json
({
status
:
'
error
'
});
}
else
{
if
(
results
.
length
>
0
)
{
return
res
.
status
(
200
).
json
({
status
:
'
true
'
});
}
else
{
return
res
.
status
(
200
).
json
({
status
:
'
false
'
});
}
}
}
);
}
else
{
return
res
.
status
(
500
).
json
({
status
:
'
error
'
});
}
}
// the routes are defined here
// the routes are defined here
//Generate new Session
//Generate new Session
...
@@ -40,26 +63,7 @@ function createRouter(db) {
...
@@ -40,26 +63,7 @@ function createRouter(db) {
//Check if Session exist
//Check if Session exist
router
.
post
(
'
/isSession
'
,
(
req
,
res
)
=>
{
router
.
post
(
'
/isSession
'
,
(
req
,
res
)
=>
{
const
spielname
=
req
.
body
.
spielname
;
isSession
(
req
,
res
)
if
(
spielname
.
match
(
/^
[
0-9a-zA-Z
]
+$/
)
!=
null
)
{
db
.
query
(
'
SELECT SessionName FROM Session WHERE SessionName =
\'
'
+
spielname
+
'
\'
;
'
,
(
error
,
results
)
=>
{
if
(
error
)
{
console
.
log
(
error
);
res
.
status
(
500
).
json
({
status
:
'
error
'
});
}
else
{
if
(
results
.
length
>
0
)
{
res
.
status
(
200
).
json
({
status
:
'
true
'
});
}
else
{
res
.
status
(
200
).
json
({
status
:
'
false
'
});
}
}
}
);
}
else
{
res
.
status
(
500
).
json
({
status
:
'
error
'
});
}
});
});
//Return all Sessions (Not neccesary)
//Return all Sessions (Not neccesary)
...
...
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