Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
augustctl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
augustctl
Commits
3b28a516
Verified
Commit
3b28a516
authored
8 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Limit request duration so that requests blocked by Bluetooth actiivty don't sit unnecessarily.
parent
c19d3b4b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
package.json
+2
-1
2 additions, 1 deletion
package.json
server.js
+12
-2
12 additions, 2 deletions
server.js
with
14 additions
and
3 deletions
package.json
+
2
−
1
View file @
3b28a516
...
...
@@ -21,7 +21,8 @@
"
morgan
"
:
"
^1.6.1
"
,
"
noble
"
:
"
^1.1.0
"
,
"
asyncawait
"
:
"
^0.7.4
"
,
"
apicache
"
:
"
*
"
"
apicache
"
:
"
*
"
,
"
connect-timeout
"
:
"
*
"
},
"repository"
:
{
"type"
:
"git"
,
...
...
This diff is collapsed.
Click to expand it.
server.js
+
12
−
2
View file @
3b28a516
...
...
@@ -11,6 +11,7 @@ var await = require( 'asyncawait/await' );
var
async
=
require
(
'
asyncawait/async
'
);
var
apicache
=
require
(
'
apicache
'
).
options
(
{
defaultDuration
:
15000
}
);
var
cache
=
apicache
.
middleware
;
var
timeout
=
require
(
'
connect-timeout
'
);
var
config
=
require
(
process
.
env
.
AUGUSTCTL_CONFIG
||
'
./config.json
'
);
var
serverConfig
=
require
(
process
.
env
.
AUGUSTCTL_SERVER_CONFIG
||
'
./server-config.json
'
);
...
...
@@ -70,12 +71,21 @@ function clearCaches( lockName ) {
return
true
;
}
// Middleware to handle timeout status checks
function
haltOnTimedout
(
req
,
res
,
next
)
{
if
(
req
.
timedout
)
{
lock
.
disconnect
();
}
else
{
next
();
}
}
/**
* ROUTES
*/
// Endpoint to check lock status
app
.
get
(
'
/api/status/:lock_name
'
,
cache
(
'
5 seconds
'
),
function
(
req
,
res
)
{
app
.
get
(
'
/api/status/:lock_name
'
,
timeout
(
'
5 seconds
'
),
cache
(
'
5 seconds
'
),
haltOnTimedout
,
function
(
req
,
res
)
{
// Parse allowed request arguments
var
lock
=
getLockInstance
(
req
.
params
.
lock_name
,
res
);
if
(
!
lock
)
{
...
...
@@ -102,7 +112,7 @@ app.get( '/api/status/:lock_name', cache( '5 seconds' ), function( req, res ) {
}
);
// Endpoint to change lock state
app
.
get
(
'
/api/:lock_action(lock|unlock)/:lock_name
'
,
cache
(
'
3 seconds
'
),
function
(
req
,
res
)
{
app
.
get
(
'
/api/:lock_action(lock|unlock)/:lock_name
'
,
timeout
(
'
5 seconds
'
),
cache
(
'
3 seconds
'
),
haltOnTimedout
,
function
(
req
,
res
)
{
// Parse allowed request arguments
var
action
=
req
.
params
.
lock_action
,
allowedActions
=
[
'
unlock
'
,
'
lock
'
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment