This repository has been archived by the owner on Dec 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
534 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
"use strict"; | ||
|
||
module.exports = [{ | ||
"path": "/_utils", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get"] | ||
}, { | ||
"role": "user", | ||
"verbs": ["get"] | ||
}] | ||
}, | ||
{ | ||
"path": "/db", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get"] | ||
}] | ||
}, | ||
{ | ||
"path": "/_utils/css", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get"] | ||
}] | ||
}, | ||
{ | ||
"path": "/_utils/js", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get"] | ||
}] | ||
}, { | ||
"path": "/_utils/img", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get"] | ||
}] | ||
}, { | ||
"path": "/_session", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get"] | ||
}] | ||
}, { | ||
"path": "/_utils/fonts", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get"] | ||
}] | ||
}, { | ||
"path": "/foobardb", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get", "put", "post"] | ||
}] | ||
}, { | ||
"path": "/_all_dbs", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get", "put", "post"] | ||
}] | ||
}, { | ||
"path": "/_utils/js/zeroclipboard", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get", "put", "post"] | ||
}] | ||
}, | ||
{ | ||
"path": "/_uuids", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get", "put", "post"] | ||
}] | ||
}, | ||
{ | ||
"path": "/favicon.ico", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get", "put", "post"] | ||
}] | ||
}]; | ||
|
||
|
||
///_uuids | ||
|
||
///_all_dbs | ||
// /_utils/js/zeroclipboard/Z | ||
//db_utils | ||
//db/css/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,43 @@ | ||
'use strict'; | ||
"use strict"; | ||
|
||
module.exports = [{ | ||
"path": '/_utils/', | ||
module.exports = [{ | ||
"path": "/_validate", | ||
"roles": [{ | ||
"role": "public", | ||
"verbs": ["get", "put", "post"] | ||
}] | ||
}, | ||
{ | ||
"path": "/foobarrepl", | ||
"roles": [{ | ||
"role": 'public', | ||
"verbs": ['get'] | ||
}, { | ||
"role": 'user', | ||
"verbs": ['get'] | ||
"role": "public", | ||
"verbs": ["get", "post", "put"] | ||
}] | ||
}, { | ||
"path": '/db/', | ||
}, | ||
{ | ||
"path": "/foobarrepl/_local", | ||
"roles": [{ | ||
"role": 'public', | ||
"verbs": ['get'] | ||
"role": "public", | ||
"verbs": ["get", "post", "put"] | ||
}] | ||
}, | ||
{ | ||
"path": '/_utils/css/', | ||
}, { | ||
"path": "/_session", | ||
"roles": [{ | ||
"role": 'public', | ||
"verbs": ['get'] | ||
"role": "public", | ||
"verbs": ["get"] | ||
}] | ||
}, | ||
{ | ||
"path": '/_utils/js/', | ||
}, { | ||
"path": "/_all_dbs", | ||
"roles": [{ | ||
"role": 'public', | ||
"verbs": ['get'] | ||
"role": "public", | ||
"verbs": ["get", "put", "post"] | ||
}] | ||
}]; | ||
}]; | ||
|
||
|
||
///_uuids | ||
|
||
///_all_dbs | ||
// /_utils/js/zeroclipboard/Z | ||
//db_utils | ||
//db/css/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
var express = require('express'); | ||
var path = require('path'); | ||
var favicon = require('serve-favicon'); | ||
var logger = require('morgan'); | ||
var cookieParser = require('cookie-parser'); | ||
var bodyParser = require('body-parser'); | ||
|
||
var routes = require('./routes/index'); | ||
|
||
var app = express(); | ||
|
||
// view engine setup | ||
app.set('views', path.join(__dirname, 'views')); | ||
app.set('view engine', 'ejs'); | ||
|
||
// uncomment after placing your favicon in /public | ||
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); | ||
app.use(logger('dev')); | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: false })); | ||
app.use(cookieParser()); | ||
app.use(express.static(path.join(__dirname, 'public'))); | ||
|
||
app.use('/node_modules', express.static( path.join(__dirname, 'node_modules'))); | ||
app.use('/app', express.static( path.join(__dirname, 'app'))); | ||
|
||
app.use('/', routes); | ||
|
||
|
||
app.use('/replicate', require('./routes/replicate')); | ||
app.use('/validate', require('./routes/validate')); | ||
|
||
// catch 404 and forward to error handler | ||
app.use(function(req, res, next) { | ||
var err = new Error('Not Found'); | ||
err.status = 404; | ||
next(err); | ||
}); | ||
|
||
// error handlers | ||
|
||
// development error handler | ||
// will print stacktrace | ||
if (app.get('env') === 'development') { | ||
app.use(function(err, req, res, next) { | ||
res.status(err.status || 500); | ||
res.render('error', { | ||
message: err.message, | ||
error: err | ||
}); | ||
}); | ||
} | ||
|
||
// production error handler | ||
// no stacktraces leaked to user | ||
app.use(function(err, req, res, next) { | ||
res.status(err.status || 500); | ||
res.render('error', { | ||
message: err.message, | ||
error: {} | ||
}); | ||
}); | ||
|
||
|
||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var myApp = angular.module('myApp', []); | ||
|
||
myApp.controller('ValidateController', ['$scope', '$http', function ($scope, $http) { | ||
$scope.greeting = 'Welcome to SALTI!'; | ||
$scope.errors = 'no errors'; | ||
$scope.messages = 'no messages'; | ||
$scope.secret = 'foobar'; | ||
$scope.newdoc = genDoc(); | ||
|
||
$scope.createDoc = function () { | ||
|
||
var body = { 'secret': 'CLEAR ' + $scope.secret, 'doc' : $scope.newdoc}; | ||
|
||
$http({ | ||
method: 'POST', | ||
url: '/validate', | ||
data: body | ||
}).then(function successCallback(response) { | ||
$scope.newdoc = genDoc(); | ||
if (response.data.secret) | ||
$scope.secret = response.data.secret; | ||
else | ||
$scope.messages = JSON.stringify(response); | ||
}, function errorCallback(response) { | ||
$scope.errors = JSON.stringify(response); | ||
}); | ||
} | ||
|
||
}]); | ||
|
||
|
||
function genDoc(){ | ||
return JSON.stringify({ _id: guid(), "type": "foobar" }) | ||
} | ||
|
||
function guid() { | ||
function s4() { | ||
return Math.floor((1 + Math.random()) * 0x10000) | ||
.toString(16) | ||
.substring(1); | ||
} | ||
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + | ||
s4() + '-' + s4() + s4() + s4(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
body { | ||
padding: 50px; | ||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; | ||
} | ||
|
||
a { | ||
color: #00B7FF; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
|
||
/* GET home page. */ | ||
router.get('/', function(req, res, next) { | ||
res.render('index', { title: 'SALTI Test Express Site' }); | ||
}); | ||
|
||
module.exports = router; |
Oops, something went wrong.