Updated to the new database schema
Signed-off-by: walamana <joniogerg@gmail.com>
This commit is contained in:
parent
27c53fe8d0
commit
f62311d20a
5
.vscode/launch.json
vendored
5
.vscode/launch.json
vendored
@ -7,7 +7,10 @@
|
||||
"name": "Launch Program",
|
||||
"program": "${workspaceRoot}/app.js",
|
||||
"env": {"PORT": "3000"},
|
||||
"cwd": "${workspaceRoot}"
|
||||
"cwd": "${workspaceRoot}",
|
||||
"args": [
|
||||
"--harmony"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
189
app.js
189
app.js
@ -4,6 +4,7 @@ var path = require("path");
|
||||
var errorHandler = require("errorhandler");
|
||||
var app = express();
|
||||
|
||||
|
||||
app.use(cookieParser());
|
||||
app.use((req, res, next) => {
|
||||
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||
@ -20,7 +21,7 @@ var cause;
|
||||
var con = mysql.createConnection({
|
||||
host: "localhost",
|
||||
user: "minis",
|
||||
password: "Wnc4q_75",
|
||||
password: "lOkw83^2",
|
||||
database: "minis"
|
||||
});
|
||||
|
||||
@ -35,49 +36,42 @@ con.connect(err => {
|
||||
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
console.log(con);
|
||||
res.send("Welcome to the miniplan api!");
|
||||
});
|
||||
|
||||
app.get('/login', (req, res) => {
|
||||
var username = req.query.username;
|
||||
var id = req.query.id;
|
||||
var password = req.query.password;
|
||||
|
||||
if(username == undefined || password == undefined){
|
||||
if(id == undefined || password == undefined){
|
||||
res.send({success: false, error: "Missing parameters"});
|
||||
return;
|
||||
}
|
||||
|
||||
username = username.toLowerCase();
|
||||
id = id.toLowerCase();
|
||||
|
||||
/*con.query("SELECT UserToken FROM ministranten WHERE Username='" + username + "'", (err, result) => {
|
||||
if(result[0]["UserToken"] == req.cookies.loginToken){
|
||||
res.send({success: true});
|
||||
}else{*/
|
||||
con.query("SELECT Passwort FROM ministranten WHERE Username='" + username + "'", (err, result) => {
|
||||
if (err) throw err;
|
||||
if(password == result[0]["Passwort"]){
|
||||
var usertoken = uuid();
|
||||
res.cookie("loginToken", usertoken);
|
||||
res.cookie("user", username);
|
||||
con.query("UPDATE `ministranten` SET `UserToken` = '" + usertoken + "' WHERE `ministranten`.`Username` = '" + username + "';");
|
||||
res.send({success: true, token: usertoken});
|
||||
}else{
|
||||
res.send({success: false});
|
||||
}
|
||||
});
|
||||
/*}
|
||||
});*/
|
||||
con.query("SELECT PASSWORT, USERNAME FROM ministranten WHERE (USERNAME='" + id + "' OR EMAIL='" + id + "')", (err, result) => {
|
||||
if (err) throw err;
|
||||
if(password == result[0]["PASSWORT"]){
|
||||
var usertoken = uuid();
|
||||
res.cookie("loginToken", usertoken);
|
||||
res.cookie("user", result[0]["USERNAME"]);
|
||||
con.query("UPDATE `ministranten` SET `USER_TOKEN` = '" + usertoken + "' WHERE `ministranten`.`USERNAME` = '" + result[0]["USERNAME"] + "';");
|
||||
res.send({success: true, token: usertoken});
|
||||
}else{
|
||||
res.send({success: false});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/logout", (req, res) => {
|
||||
var token = req.cookies.loginToken;
|
||||
var user = req.cookies.user;
|
||||
|
||||
con.query("SELECT UserToken FROM ministranten WHERE Username='" + user + "'", (err, result) => {
|
||||
if (err) throw err;
|
||||
|
||||
if(result[0]["UserToken"] != "" && result[0]["UserToken"] == token){
|
||||
con.query("UPDATE `ministranten` SET `UserToken` = '' WHERE `ministranten`.`Username` = '" + user + "';");
|
||||
tokenIsValid(user, token).then(valid => {
|
||||
if(valid){
|
||||
con.query("UPDATE `ministranten` SET `USER_TOKEN` = '' WHERE `ministranten`.`USERNAME` = '" + user + "';");
|
||||
res.cookie("loginToken", "");
|
||||
res.cookie("user", "");
|
||||
res.send({success: true});
|
||||
@ -89,70 +83,120 @@ app.get("/logout", (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
app.get("/user/:user/update", (req, res) => {
|
||||
app.get("/loggedIn", (req, res) => {
|
||||
var token = req.cookies.loginToken;
|
||||
var user = req.cookies.user;
|
||||
|
||||
tokenIsValid(user, token).then(valid => {
|
||||
if(valid){
|
||||
res.send({success: true, loggedIn: true, user: user});
|
||||
}else{
|
||||
res.send({success: true, loggedIn: false, user: user});
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* WIP
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
app.get("/:user/update", (req, res) => {
|
||||
var token = req.cookies.loginToken;
|
||||
var user = req.params.user;
|
||||
var changes = JSON.parse(req.query.changes);
|
||||
|
||||
|
||||
tokenIsValid(req.cookies.user, token).then(valid => {
|
||||
if(valid){
|
||||
if(req.cookies.user != "admin" && req.cookies.user != user){
|
||||
res.send({success: false, error: "Unauthorized"});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Changing for " + user + " as " + req.cookies.user + " following states: ");
|
||||
console.log(changes);
|
||||
for(var i = 0; i < Object.keys(changes).length; i++){
|
||||
var gdID = Object.keys(changes)[i];
|
||||
var anwesenheit = changes[Object.keys(changes)[i]];
|
||||
con.query("INSERT INTO `anwesenheit` (USERNAME, gottesdienst_ID, ANWESENHEIT) VALUES('" + user + "', " + gdID + ", " + anwesenheit + ") ON DUPLICATE KEY UPDATE USERNAME='" + user + "', gottesdienst_ID=" + gdID + ", ANWESENHEIT=" + anwesenheit + "")
|
||||
}
|
||||
|
||||
res.send({success: true});
|
||||
}else{
|
||||
console.log("Unauthorized not valid");
|
||||
res.send({success: false, error: "Unauthorized"});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
app.get("/gottesdienste", (req, res) => {
|
||||
var groupid = req.params.groupid;
|
||||
con.query("SELECT ID from gottesdienstGruppe ORDER BY ID DESC LIMIT 1", (err, result) => {
|
||||
con.query("SELECT ID from gruppe ORDER BY ID DESC LIMIT 1", (err, result) => {
|
||||
if (err) throw err;
|
||||
con.query("SELECT * from gottesdienste WHERE GruppeID='" + result[0]["ID"] + "' ORDER BY `gottesdienste`.`Datum` ASC LIMIT 0 , 30 ", (err, result) => {
|
||||
con.query("SELECT * from gottesdienst WHERE gruppe_ID='" + result[0]["ID"] + "' ORDER BY `gottesdienst`.`DATUM` ASC LIMIT 0 , 30 ", (err, result) => {
|
||||
if (err) throw err;
|
||||
res.send(JSON.stringify(result));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
app.get("/gottesdienste/:groupid", (req, res) => {
|
||||
var groupid = req.params.groupid;
|
||||
con.query("SELECT * from gottesdienste WHERE GruppeID='" + groupid + "' ORDER BY `gottesdienste`.`Datum` ASC LIMIT 0 , 30", (err, result) => {
|
||||
con.query("SELECT * from gottesdienst WHERE gruppe_ID='" + groupid + "' ORDER BY `gottesdienst`.`DATUM` ASC LIMIT 0 , 30", (err, result) => {
|
||||
if (err) throw err;
|
||||
res.send(JSON.stringify(result));
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/groups", (req, res) => {
|
||||
con.query("SELECT * from gottesdienstGruppe ORDER BY `gottesdienstGruppe`.`ID` DESC LIMIT 0, 5", (err, result) => {
|
||||
con.query("SELECT * from gruppe ORDER BY `gruppe`.`ID` DESC LIMIT 0, 5", (err, result) => {
|
||||
if (err) throw err;
|
||||
res.send(JSON.stringify(result));
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/ministranten", (req, res) =>{
|
||||
con.query("SELECT UserToken FROM ministranten WHERE UserToken='" + req.cookies.loginToken + "'", (err, result) => {
|
||||
var loggedIn = result.length == 1;
|
||||
con.query("SELECT Name, Username FROM `ministranten`", (err, result) => {
|
||||
tokenIsValid(req.cookies.user, req.cookies.loginToken).then(valid => {
|
||||
con.query("SELECT `ministranten`.`USERNAME`, `ministranten`.`VORNAME`, `ministranten`.`NACHNAME`, `anwesenheit`.`ANWESENHEIT`, `anwesenheit`.`gottesdienst_ID` FROM `ministranten` LEFT JOIN `anwesenheit` ON `anwesenheit`.`USERNAME` = `ministranten`.`USERNAME` ORDER BY `ministranten`.`NACHNAME`, `ministranten`.`VORNAME`, `anwesenheit`.`gottesdienst_ID` DESC LIMIT 30", (err, results) => {
|
||||
if (err) throw err;
|
||||
var minis = result;
|
||||
var minis = [];
|
||||
|
||||
var finished = 0;
|
||||
|
||||
minis.splice(0, 1);
|
||||
for(var i = 0; i < minis.length; i++){
|
||||
attachToMini(minis[i], i, (mini, pos) => {
|
||||
minis[pos] = mini;
|
||||
finished++;
|
||||
if(finished == minis.length){
|
||||
if(!loggedIn){
|
||||
for(var i = 0; i < minis.length; i++){
|
||||
if(minis[i]["Name"] == "admin"){
|
||||
minis.splice(0, 1);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
minis[i]["Name"] = minis[i]["Name"].split(" ")[0].substring(0, 1) + ". " + minis[i]["Name"].split(" ")[1];
|
||||
}
|
||||
}
|
||||
res.send(JSON.stringify(minis));
|
||||
var curMini;
|
||||
for(var i = 0; i < results.length; i++){
|
||||
|
||||
var result = results[i];
|
||||
if(result["USERNAME"] == "admin"){
|
||||
continue;
|
||||
}
|
||||
if(!curMini || curMini.username != result["USERNAME"]){
|
||||
if(curMini != undefined || curMini != null){
|
||||
minis.push(curMini);
|
||||
}
|
||||
});
|
||||
curMini = {
|
||||
firstname: result["VORNAME"],
|
||||
lastname: valid ? result["NACHNAME"] : result["NACHNAME"].substring(0, 1) + ".",
|
||||
username: result["USERNAME"],
|
||||
registered: {}
|
||||
}
|
||||
}
|
||||
curMini.registered[result["gottesdienst_ID"]] = result["ANWESENHEIT"];
|
||||
}
|
||||
minis.push(curMini);
|
||||
|
||||
res.send(JSON.stringify(minis));
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
var attachToMini = function(mini, pos, then){
|
||||
@ -161,7 +205,6 @@ var attachToMini = function(mini, pos, then){
|
||||
if(data == null){
|
||||
then(mini, pos);
|
||||
}
|
||||
console.log(data);
|
||||
for(var j = 0; j < data.length; j++){
|
||||
|
||||
mini.registered[j] = {
|
||||
@ -179,18 +222,30 @@ console.log("Starting api-server on " + process.env.PORT);
|
||||
|
||||
|
||||
|
||||
function tokenIsValid(username, token){
|
||||
return new Promise((resolve, reject) => {
|
||||
con.query("SELECT USER_TOKEN FROM ministranten WHERE USERNAME='" + username + "'", (err, result) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
|
||||
function isConnected(){
|
||||
if(con.isConnected){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
if(result.length == 0){
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(result[0]["USER_TOKEN"] != "" && result[0]["USER_TOKEN"] == token){
|
||||
resolve(true);
|
||||
}else{
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
function removeFromArrayByValue(value, array) {
|
||||
var index = array.indexOf(value);
|
||||
if(index > -1){
|
||||
|
||||
28
node_modules/hashmap/.jshintrc
generated
vendored
Normal file
28
node_modules/hashmap/.jshintrc
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"shadow": "inner",
|
||||
"indent": 1,
|
||||
|
||||
"camelcase": false,
|
||||
"eqeqeq": true,
|
||||
"eqnull": true,
|
||||
"freeze": true,
|
||||
"funcscope": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonbsp": true,
|
||||
"unused": "vars",
|
||||
"undef": true,
|
||||
"scripturl": true,
|
||||
"loopfunc": true,
|
||||
"strict": "implied",
|
||||
"validthis": true,
|
||||
|
||||
"esnext": true,
|
||||
"globals": {},
|
||||
"browser": true,
|
||||
"devel": true,
|
||||
"mocha": true,
|
||||
"node": true,
|
||||
"jquery": true
|
||||
}
|
||||
52
node_modules/hashmap/CHANGELOG.md
generated
vendored
Normal file
52
node_modules/hashmap/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
# Changelog
|
||||
|
||||
## 2.3.0
|
||||
- Constructor now supports a 2D array 2D of key-value pair. Thanks @ulikoehler
|
||||
- Renamed `remove()` to `delete()`. `remove()` is now deprecated and kept temporarily. Thanks @ulikoehler
|
||||
- Added `.size` member. `count()` is now deprecated and kept temporarily. Thanks @ulikoehler
|
||||
|
||||
## 2.2.0
|
||||
- Added entries() method to hashmaps. Thanks @ulikoehler
|
||||
|
||||
## 2.1.0
|
||||
- support ECMA 5 non-conformant behaviour of Microsoft edge #27. Thanks @freddiecoleman
|
||||
|
||||
## 2.0.6
|
||||
- Names of chained methods is hardcoded rather than using the "return" trick. Fixes bug when minified, thanks @fresheneesz.
|
||||
- Added jshint to be run before any commit
|
||||
|
||||
## 2.0.5
|
||||
- count() is now O(1), thanks @qbolec
|
||||
|
||||
## 2.0.4
|
||||
- hasOwnProperty() is used to check for the internal expando, thanks @psionski
|
||||
|
||||
## 2.0.3
|
||||
- forEach method accepts a context as 2nd argument, thanks @mvayngrib
|
||||
|
||||
## 2.0.2
|
||||
- Make collisions rarer
|
||||
|
||||
## 2.0.1
|
||||
- AMD CommonJS export is now compatible
|
||||
|
||||
## 2.0.0
|
||||
- Added chaining to all methods with no returned value
|
||||
- Added multi() method
|
||||
- Added clone() method
|
||||
- Added copy() method
|
||||
- constructor accepts one argument for cloning or several for multi()
|
||||
|
||||
## 1.2.0
|
||||
- Added search() method, thanks @rafalwrzeszcz
|
||||
|
||||
## 1.1.0
|
||||
- AMD support, thanks @khrome
|
||||
|
||||
## 1.0.1
|
||||
- forEach() callback receives the hashmap as `this`
|
||||
- Added keys()
|
||||
- Added values()
|
||||
|
||||
## 1.0.0
|
||||
- First release
|
||||
22
node_modules/hashmap/LICENSE
generated
vendored
Normal file
22
node_modules/hashmap/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 Ariel Flesler <aflesler@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
170
node_modules/hashmap/Readme.md
generated
vendored
Normal file
170
node_modules/hashmap/Readme.md
generated
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
# HashMap Class for JavaScript
|
||||
|
||||
## Installation
|
||||
|
||||
[](https://npmjs.org/package/hashmap)
|
||||
|
||||
Using [npm](https://npmjs.org/package/hashmap):
|
||||
|
||||
$ npm install hashmap
|
||||
|
||||
Using bower:
|
||||
|
||||
$ bower install hashmap
|
||||
|
||||
You can download the last stable version from the [releases page](https://github.com/flesler/hashmap/releases).
|
||||
|
||||
If you like risk, you can download the [latest master version](https://raw.github.com/flesler/hashmap/master/hashmap.js), it's usually stable.
|
||||
|
||||
To run the tests:
|
||||
|
||||
$ npm test
|
||||
|
||||
## Description
|
||||
|
||||
This project provides a `HashMap` class that works both on __Node.js__ and the __browser__.
|
||||
HashMap instances __store key/value pairs__ allowing __keys of any type__.
|
||||
|
||||
Unlike regular objects, __keys will not be stringified__. For example numbers and strings won't be mixed, you can pass `Date`'s, `RegExp`'s, DOM Elements, anything! (even `null` and `undefined`)
|
||||
|
||||
## HashMap constructor overloads
|
||||
- `new HashMap()` creates an empty hashmap
|
||||
- `new HashMap(map:HashMap)` creates a hashmap with the key-value pairs of `map`
|
||||
- `new HashMap(arr:Array)` creates a hashmap from the 2D key-value array `arr`, e.g. `[['key1','val1'], ['key2','val2']]`
|
||||
- `new HashMap(key:*, value:*, key2:*, value2:*, ...)` creates a hashmap with several key-value pairs
|
||||
|
||||
## HashMap methods
|
||||
|
||||
- `get(key:*) : *` returns the value stored for that key.
|
||||
- `set(key:*, value:*) : HashMap` stores a key-value pair
|
||||
- `multi(key:*, value:*, key2:*, value2:*, ...) : HashMap` stores several key-value pairs
|
||||
- `copy(other:HashMap) : HashMap` copies all key-value pairs from other to this instance
|
||||
- `has(key:*) : Boolean` returns whether a key is set on the hashmap
|
||||
- `search(value:*) : *` returns key under which given value is stored (`null` if not found)
|
||||
- `delete(key:*) : HashMap` deletes a key-value pair by key
|
||||
- `remove(key:*) : HashMap` Alias for `delete(key:*)` *(deprecated)*
|
||||
- `type(key:*) : String` returns the data type of the provided key (used internally)
|
||||
- `keys() : Array<*>` returns an array with all the registered keys
|
||||
- `values() : Array<*>` returns an array with all the values
|
||||
- `entries() : Array<[*,*]>` returns an array with [key,value] pairs
|
||||
- `size : Number` the amount of key-value pairs
|
||||
- `count() : Number` returns the amount of key-value pairs *(deprecated)*
|
||||
- `clear() : HashMap` deletes all the key-value pairs on the hashmap
|
||||
- `clone() : HashMap` creates a new hashmap with all the key-value pairs of the original
|
||||
- `hash(key:*) : String` returns the stringified version of a key (used internally)
|
||||
- `forEach(function(value, key)) : HashMap` iterates the pairs and calls the function for each one
|
||||
|
||||
### Method chaining
|
||||
|
||||
All methods that don't return something, will return the HashMap instance to enable chaining.
|
||||
|
||||
## Examples
|
||||
|
||||
Assume this for all examples below
|
||||
|
||||
```js
|
||||
var map = new HashMap();
|
||||
```
|
||||
|
||||
If you're using this within Node, you first need to import the class
|
||||
|
||||
```js
|
||||
var HashMap = require('hashmap');
|
||||
```
|
||||
|
||||
### Basic use case
|
||||
|
||||
```js
|
||||
map.set("some_key", "some value");
|
||||
map.get("some_key"); // --> "some value"
|
||||
```
|
||||
|
||||
### Map size / number of elements
|
||||
|
||||
```js
|
||||
var map = new HashMap();
|
||||
map.set("key1", "val1");
|
||||
map.set("key2", "val2");
|
||||
map.size; // -> 2
|
||||
```
|
||||
|
||||
### Deleting key-value pairs
|
||||
|
||||
```js
|
||||
map.set("some_key", "some value");
|
||||
map.delete("some_key");
|
||||
map.get("some_key"); // --> undefined
|
||||
```
|
||||
|
||||
### No stringification
|
||||
|
||||
```js
|
||||
map.set("1", "string one");
|
||||
map.set(1, "number one");
|
||||
map.get("1"); // --> "string one"
|
||||
```
|
||||
|
||||
A regular `Object` used as a map would yield `"number one"`
|
||||
|
||||
### Objects as keys
|
||||
|
||||
```js
|
||||
var key = {};
|
||||
var key2 = {};
|
||||
map.set(key, 123);
|
||||
map.set(key2, 321);
|
||||
map.get(key); // --> 123
|
||||
```
|
||||
A regular `Object` used as a map would yield `321`
|
||||
|
||||
### Iterating
|
||||
|
||||
```js
|
||||
map.set(1, "test 1");
|
||||
map.set(2, "test 2");
|
||||
map.set(3, "test 3");
|
||||
|
||||
map.forEach(function(value, key) {
|
||||
console.log(key + " : " + value);
|
||||
});
|
||||
```
|
||||
|
||||
### Method chaining
|
||||
|
||||
```js
|
||||
map
|
||||
.set(1, "test 1")
|
||||
.set(2, "test 2")
|
||||
.set(3, "test 3")
|
||||
.forEach(function(value, key) {
|
||||
console.log(key + " : " + value);
|
||||
});
|
||||
```
|
||||
|
||||
## LICENSE
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Ariel Flesler
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF
|
||||
|
||||
## To-Do
|
||||
|
||||
* (?) Allow extending the hashing function in a AOP way or by passing a service
|
||||
* Make tests work on the browser
|
||||
29
node_modules/hashmap/bower.json
generated
vendored
Normal file
29
node_modules/hashmap/bower.json
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "hashmap",
|
||||
"version": "2.3.0",
|
||||
"description": "HashMap Class for JavaScript",
|
||||
"homepage": "https://github.com/flesler/hashmap",
|
||||
"main": "./hashmap.js",
|
||||
"dependencies": {},
|
||||
"keywords": [
|
||||
"hashmap",
|
||||
"map",
|
||||
"object",
|
||||
"array",
|
||||
"associative",
|
||||
"javascript",
|
||||
"nodejs",
|
||||
"node",
|
||||
"browser"
|
||||
],
|
||||
"author": {
|
||||
"name": "Ariel Flesler",
|
||||
"web": "https://github.com/flesler"
|
||||
},
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"test",
|
||||
"components"
|
||||
]
|
||||
}
|
||||
210
node_modules/hashmap/hashmap.js
generated
vendored
Normal file
210
node_modules/hashmap/hashmap.js
generated
vendored
Normal file
@ -0,0 +1,210 @@
|
||||
/**
|
||||
* HashMap - HashMap Class for JavaScript
|
||||
* @author Ariel Flesler <aflesler@gmail.com>
|
||||
* @version 2.0.6
|
||||
* Homepage: https://github.com/flesler/hashmap
|
||||
*/
|
||||
|
||||
(function(factory) {
|
||||
/* global define */
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define([], factory);
|
||||
} else if (typeof module === 'object') {
|
||||
// Node js environment
|
||||
var HashMap = module.exports = factory();
|
||||
// Keep it backwards compatible
|
||||
HashMap.HashMap = HashMap;
|
||||
} else {
|
||||
// Browser globals (this is window)
|
||||
this.HashMap = factory();
|
||||
}
|
||||
}(function() {
|
||||
|
||||
function HashMap(other) {
|
||||
this.clear();
|
||||
switch (arguments.length) {
|
||||
case 0: break;
|
||||
case 1: {
|
||||
if ('length' in other) {
|
||||
// Flatten 2D array to alternating key-value array
|
||||
multi(this, Array.prototype.concat.apply([], other));
|
||||
} else { // Assumed to be a HashMap instance
|
||||
this.copy(other);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: multi(this, arguments); break;
|
||||
}
|
||||
}
|
||||
|
||||
var proto = HashMap.prototype = {
|
||||
constructor:HashMap,
|
||||
|
||||
get:function(key) {
|
||||
var data = this._data[this.hash(key)];
|
||||
return data && data[1];
|
||||
},
|
||||
|
||||
set:function(key, value) {
|
||||
// Store original key as well (for iteration)
|
||||
var hash = this.hash(key);
|
||||
if ( !(hash in this._data) ) {
|
||||
this.size++;
|
||||
}
|
||||
this._data[hash] = [key, value];
|
||||
},
|
||||
|
||||
multi:function() {
|
||||
multi(this, arguments);
|
||||
},
|
||||
|
||||
copy:function(other) {
|
||||
for (var hash in other._data) {
|
||||
if ( !(hash in this._data) ) {
|
||||
this.size++;
|
||||
}
|
||||
this._data[hash] = other._data[hash];
|
||||
}
|
||||
},
|
||||
|
||||
has:function(key) {
|
||||
return this.hash(key) in this._data;
|
||||
},
|
||||
|
||||
search:function(value) {
|
||||
for (var key in this._data) {
|
||||
if (this._data[key][1] === value) {
|
||||
return this._data[key][0];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
delete:function(key) {
|
||||
var hash = this.hash(key);
|
||||
if ( hash in this._data ) {
|
||||
this.size--;
|
||||
delete this._data[hash];
|
||||
}
|
||||
},
|
||||
|
||||
type:function(key) {
|
||||
var str = Object.prototype.toString.call(key);
|
||||
var type = str.slice(8, -1).toLowerCase();
|
||||
// Some browsers yield DOMWindow or Window for null and undefined, works fine on Node
|
||||
if (!key && (type === 'domwindow' || type === 'window')) {
|
||||
return key + '';
|
||||
}
|
||||
return type;
|
||||
},
|
||||
|
||||
keys:function() {
|
||||
var keys = [];
|
||||
this.forEach(function(_, key) { keys.push(key); });
|
||||
return keys;
|
||||
},
|
||||
|
||||
values:function() {
|
||||
var values = [];
|
||||
this.forEach(function(value) { values.push(value); });
|
||||
return values;
|
||||
},
|
||||
|
||||
entries:function() {
|
||||
var entries = [];
|
||||
this.forEach(function(value, key) { entries.push([key, value]); });
|
||||
return entries;
|
||||
},
|
||||
|
||||
// TODO: This is deprecated and will be deleted in a future version
|
||||
count:function() {
|
||||
return this.size;
|
||||
},
|
||||
|
||||
clear:function() {
|
||||
// TODO: Would Object.create(null) make any difference
|
||||
this._data = {};
|
||||
this.size = 0;
|
||||
},
|
||||
|
||||
clone:function() {
|
||||
return new HashMap(this);
|
||||
},
|
||||
|
||||
hash:function(key) {
|
||||
switch (this.type(key)) {
|
||||
case 'undefined':
|
||||
case 'null':
|
||||
case 'boolean':
|
||||
case 'number':
|
||||
case 'regexp':
|
||||
return key + '';
|
||||
|
||||
case 'date':
|
||||
return '♣' + key.getTime();
|
||||
|
||||
case 'string':
|
||||
return '♠' + key;
|
||||
|
||||
case 'array':
|
||||
var hashes = [];
|
||||
for (var i = 0; i < key.length; i++) {
|
||||
hashes[i] = this.hash(key[i]);
|
||||
}
|
||||
return '♥' + hashes.join('⁞');
|
||||
|
||||
default:
|
||||
// TODO: Don't use expandos when Object.defineProperty is not available?
|
||||
if (!key.hasOwnProperty('_hmuid_')) {
|
||||
key._hmuid_ = ++HashMap.uid;
|
||||
hide(key, '_hmuid_');
|
||||
}
|
||||
|
||||
return '♦' + key._hmuid_;
|
||||
}
|
||||
},
|
||||
|
||||
forEach:function(func, ctx) {
|
||||
for (var key in this._data) {
|
||||
var data = this._data[key];
|
||||
func.call(ctx || this, data[1], data[0]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
HashMap.uid = 0;
|
||||
|
||||
//- Add chaining to all methods that don't return something
|
||||
|
||||
['set','multi','copy','delete','clear','forEach'].forEach(function(method) {
|
||||
var fn = proto[method];
|
||||
proto[method] = function() {
|
||||
fn.apply(this, arguments);
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
||||
//- Backwards compatibility
|
||||
|
||||
// TODO: remove() is deprecated and will be deleted in a future version
|
||||
HashMap.prototype.remove = HashMap.prototype.delete;
|
||||
|
||||
//- Utils
|
||||
|
||||
function multi(map, args) {
|
||||
for (var i = 0; i < args.length; i += 2) {
|
||||
map.set(args[i], args[i+1]);
|
||||
}
|
||||
}
|
||||
|
||||
function hide(obj, prop) {
|
||||
// Make non iterable if supported
|
||||
if (Object.defineProperty) {
|
||||
Object.defineProperty(obj, prop, {enumerable:false});
|
||||
}
|
||||
}
|
||||
|
||||
return HashMap;
|
||||
}));
|
||||
71
node_modules/hashmap/package.json
generated
vendored
Normal file
71
node_modules/hashmap/package.json
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
{
|
||||
"_from": "hashmap",
|
||||
"_id": "hashmap@2.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-sT+2XafIul49uPwbjFuh0ASdryI=",
|
||||
"_location": "/hashmap",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "hashmap",
|
||||
"name": "hashmap",
|
||||
"escapedName": "hashmap",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/hashmap/-/hashmap-2.3.0.tgz",
|
||||
"_shasum": "b13fb65da7c8ba5e3db8fc1b8c5ba1d0049daf22",
|
||||
"_spec": "hashmap",
|
||||
"_where": "C:\\Users\\jonio\\Documents\\Programmieren\\Miniportal\\Neu\\MiniportalAPI",
|
||||
"author": {
|
||||
"name": "Ariel Flesler",
|
||||
"url": "https://github.com/flesler"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/flesler/hashmap/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "HashMap Class for JavaScript",
|
||||
"devDependencies": {
|
||||
"chai": "4.1.1",
|
||||
"husky": "0.14.3",
|
||||
"jshint": "2.9.5",
|
||||
"mocha": "3.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"homepage": "https://github.com/flesler/hashmap",
|
||||
"keywords": [
|
||||
"hashmap",
|
||||
"map",
|
||||
"object",
|
||||
"array",
|
||||
"associative",
|
||||
"javascript",
|
||||
"nodejs",
|
||||
"node",
|
||||
"browser"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./hashmap.js",
|
||||
"name": "hashmap",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/flesler/hashmap.git"
|
||||
},
|
||||
"scripts": {
|
||||
"precommit": "jshint hashmap.js",
|
||||
"prepush": "npm run test",
|
||||
"test": "mocha test/ --reporter dot"
|
||||
},
|
||||
"version": "2.3.0"
|
||||
}
|
||||
23
node_modules/underscore/LICENSE
generated
vendored
Normal file
23
node_modules/underscore/LICENSE
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
Copyright (c) 2009-2017 Jeremy Ashkenas, DocumentCloud and Investigative
|
||||
Reporters & Editors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
28
node_modules/underscore/README.md
generated
vendored
Normal file
28
node_modules/underscore/README.md
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
__
|
||||
/\ \ __
|
||||
__ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
|
||||
/\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
|
||||
\ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
|
||||
\ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
|
||||
\/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
|
||||
\ \____/
|
||||
\/___/
|
||||
|
||||
Underscore.js is a utility-belt library for JavaScript that provides
|
||||
support for the usual functional suspects (each, map, reduce, filter...)
|
||||
without extending any core JavaScript objects.
|
||||
|
||||
For Docs, License, Tests, and pre-packed downloads, see:
|
||||
http://underscorejs.org
|
||||
|
||||
For support and questions, please use
|
||||
[the gitter channel](https://gitter.im/jashkenas/underscore)
|
||||
or [stackoverflow](http://stackoverflow.com/search?q=underscore.js)
|
||||
|
||||
Underscore is an open-sourced component of DocumentCloud:
|
||||
https://github.com/documentcloud
|
||||
|
||||
Many thanks to our contributors:
|
||||
https://github.com/jashkenas/underscore/contributors
|
||||
|
||||
This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
|
||||
82
node_modules/underscore/package.json
generated
vendored
Normal file
82
node_modules/underscore/package.json
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
{
|
||||
"_from": "underscore",
|
||||
"_id": "underscore@1.9.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-4IV1DSSxC1QK48j9ONFK1MoIAKKkbE8i7u55w2R6IqBqbT7A/iG7aZBCR2Bi8piF0Uz+i/MG1aeqLwl/5vqF+A==",
|
||||
"_location": "/underscore",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "underscore",
|
||||
"name": "underscore",
|
||||
"escapedName": "underscore",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.0.tgz",
|
||||
"_shasum": "31dbb314cfcc88f169cd3692d9149d81a00a73e4",
|
||||
"_spec": "underscore",
|
||||
"_where": "C:\\Users\\jonio\\Documents\\Programmieren\\Miniportal\\Neu\\MiniportalAPI",
|
||||
"author": {
|
||||
"name": "Jeremy Ashkenas",
|
||||
"email": "jeremy@documentcloud.org"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jashkenas/underscore/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "JavaScript's functional programming helper library.",
|
||||
"devDependencies": {
|
||||
"coveralls": "^2.11.2",
|
||||
"docco": "*",
|
||||
"eslint": "1.10.x",
|
||||
"gzip-size-cli": "^1.0.0",
|
||||
"karma": "^0.13.13",
|
||||
"karma-qunit": "~2.0.1",
|
||||
"nyc": "^2.1.3",
|
||||
"pretty-bytes-cli": "^1.0.0",
|
||||
"qunit": "^2.6.0",
|
||||
"qunit-cli": "~0.2.0",
|
||||
"uglify-js": "3.3.21"
|
||||
},
|
||||
"files": [
|
||||
"underscore.js",
|
||||
"underscore-min.js",
|
||||
"underscore-min.js.map"
|
||||
],
|
||||
"homepage": "http://underscorejs.org",
|
||||
"keywords": [
|
||||
"util",
|
||||
"functional",
|
||||
"server",
|
||||
"client",
|
||||
"browser"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "underscore.js",
|
||||
"name": "underscore",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/jashkenas/underscore.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run minify -- --source-map --source-map-url \" \" -o underscore-min.js",
|
||||
"coverage": "nyc npm run test-node && nyc report",
|
||||
"coveralls": "nyc npm run test-node && nyc report --reporter=text-lcov | coveralls",
|
||||
"doc": "docco underscore.js",
|
||||
"lint": "eslint underscore.js test/*.js",
|
||||
"minify": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m",
|
||||
"test": "npm run test-node && npm run lint",
|
||||
"test-browser": "npm i karma-phantomjs-launcher && karma start",
|
||||
"test-node": "qunit-cli test/*.js",
|
||||
"weight": "npm run minify | gzip-size | pretty-bytes"
|
||||
},
|
||||
"version": "1.9.0"
|
||||
}
|
||||
5
node_modules/underscore/underscore-min.js
generated
vendored
Normal file
5
node_modules/underscore/underscore-min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/underscore/underscore-min.js.map
generated
vendored
Normal file
1
node_modules/underscore/underscore-min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1688
node_modules/underscore/underscore.js
generated
vendored
Normal file
1688
node_modules/underscore/underscore.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10
package-lock.json
generated
10
package-lock.json
generated
@ -195,6 +195,11 @@
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
|
||||
},
|
||||
"hashmap": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/hashmap/-/hashmap-2.3.0.tgz",
|
||||
"integrity": "sha1-sT+2XafIul49uPwbjFuh0ASdryI="
|
||||
},
|
||||
"http-errors": {
|
||||
"version": "1.6.2",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz",
|
||||
@ -510,6 +515,11 @@
|
||||
"mime-types": "2.1.17"
|
||||
}
|
||||
},
|
||||
"underscore": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.0.tgz",
|
||||
"integrity": "sha512-4IV1DSSxC1QK48j9ONFK1MoIAKKkbE8i7u55w2R6IqBqbT7A/iG7aZBCR2Bi8piF0Uz+i/MG1aeqLwl/5vqF+A=="
|
||||
},
|
||||
"unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
|
||||
@ -13,8 +13,10 @@
|
||||
"errorhandler": "^1.5.0",
|
||||
"express": "^4.16.1",
|
||||
"express-force-ssl": "^0.3.2",
|
||||
"hashmap": "^2.3.0",
|
||||
"mysql": "^2.15.0",
|
||||
"path": "^0.12.7",
|
||||
"underscore": "^1.9.0",
|
||||
"uuid": "^3.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user