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
316b1078
Verified
Commit
316b1078
authored
8 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Reorganization and inline doc
parent
6b58e90e
Branches
Branches containing commit
Tags
v1.0.0
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.js
+37
-21
37 additions, 21 deletions
server.js
with
37 additions
and
21 deletions
server.js
+
37
−
21
View file @
316b1078
'
use strict
'
;
/**
* LIBRARIES
*/
var
augustctl
=
require
(
'
./index
'
);
var
express
=
require
(
'
express
'
);
var
morgan
=
require
(
'
morgan
'
);
...
...
@@ -18,6 +22,10 @@ var port = serverConfig.port || 3000;
var
app
=
express
();
app
.
use
(
morgan
(
DEBUG
?
'
dev
'
:
'
combined
'
)
);
/**
* UTILITIES
*/
// Default return arguments
var
ret
=
{
'
status
'
:
-
1
,
...
...
@@ -25,6 +33,32 @@ var ret = {
'
msg
'
:
''
};
// Convert named status to integer representation
function
statusStringtoInt
(
status
)
{
var
statusInt
=
-
1
;
if
(
'
locked
'
===
status
)
{
statusInt
=
0
;
}
else
if
(
'
unlocked
'
===
status
)
{
statusInt
=
1
;
}
return
statusInt
;
}
// Clear cached routes
function
clear_caches
(
lockName
)
{
apicache
.
clear
(
'
/api/status/
'
+
lockName
);
apicache
.
clear
(
'
/api/lock/
'
+
lockName
);
apicache
.
clear
(
'
/api/unlock/
'
+
lockName
);
return
true
;
}
/**
* ROUTES
*/
// Endpoint to check lock status
app
.
get
(
'
/api/status/:lock_name
'
,
cache
(
'
15 seconds
'
),
function
(
req
,
res
)
{
// Parse allowed request arguments
...
...
@@ -125,27 +159,9 @@ app.get( '/api/disconnect/:lock_name', function( req, res ) {
res
.
sendStatus
(
204
);
}
);
// Convert named status to integer representation
function
statusStringtoInt
(
status
)
{
var
statusInt
=
-
1
;
if
(
'
locked
'
===
status
)
{
statusInt
=
0
;
}
else
if
(
'
unlocked
'
===
status
)
{
statusInt
=
1
;
}
return
statusInt
;
}
// Clear cached routes
function
clear_caches
(
lockName
)
{
apicache
.
clear
(
'
/api/status/
'
+
lockName
);
apicache
.
clear
(
'
/api/lock/
'
+
lockName
);
apicache
.
clear
(
'
/api/unlock/
'
+
lockName
);
return
true
;
}
/**
* SERVER SETUP
*/
// Parse lock configurations
Object
.
keys
(
config
).
forEach
(
function
(
lockName
)
{
...
...
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