This repository has been archived by the owner on Nov 12, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
b78574f
commit 6211909
Showing
69 changed files
with
22,483 additions
and
1 deletion.
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,40 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Ignore all compiled JS | ||
public/js/components/**/*.js | ||
public/js/components/**/*.map | ||
public/js/core/**/*.js | ||
public/js/core/**/*.map |
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,62 @@ | ||
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 api = require('./routes/api/api'); | ||
|
||
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('/', routes); | ||
app.use('/api/', api); | ||
|
||
// 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, | ||
code: err.status | ||
}); | ||
}); | ||
} | ||
|
||
// 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: {}, | ||
code: err.status | ||
}); | ||
}); | ||
|
||
|
||
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,90 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var app = require('../app'); | ||
var debug = require('debug')('uq-parking-stats:server'); | ||
var http = require('http'); | ||
|
||
/** | ||
* Get port from environment and store in Express. | ||
*/ | ||
|
||
var port = normalizePort(process.env.PORT || '3000'); | ||
app.set('port', port); | ||
|
||
/** | ||
* Create HTTP server. | ||
*/ | ||
|
||
var server = http.createServer(app); | ||
|
||
/** | ||
* Listen on provided port, on all network interfaces. | ||
*/ | ||
|
||
server.listen(port); | ||
server.on('error', onError); | ||
server.on('listening', onListening); | ||
|
||
/** | ||
* Normalize a port into a number, string, or false. | ||
*/ | ||
|
||
function normalizePort(val) { | ||
var port = parseInt(val, 10); | ||
|
||
if (isNaN(port)) { | ||
// named pipe | ||
return val; | ||
} | ||
|
||
if (port >= 0) { | ||
// port number | ||
return port; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "error" event. | ||
*/ | ||
|
||
function onError(error) { | ||
if (error.syscall !== 'listen') { | ||
throw error; | ||
} | ||
|
||
var bind = typeof port === 'string' | ||
? 'Pipe ' + port | ||
: 'Port ' + port; | ||
|
||
// handle specific listen errors with friendly messages | ||
switch (error.code) { | ||
case 'EACCES': | ||
console.error(bind + ' requires elevated privileges'); | ||
process.exit(1); | ||
break; | ||
case 'EADDRINUSE': | ||
console.error(bind + ' is already in use'); | ||
process.exit(1); | ||
break; | ||
default: | ||
throw error; | ||
} | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "listening" event. | ||
*/ | ||
|
||
function onListening() { | ||
var addr = server.address(); | ||
var bind = typeof addr === 'string' | ||
? 'pipe ' + addr | ||
: 'port ' + addr.port; | ||
debug('Listening on ' + bind); | ||
} |
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 @@ | ||
module.exports = { | ||
mysql: { | ||
host: "localhost", | ||
port: 3306, | ||
user: "uniber", | ||
password: "uniber", | ||
database: "uniber" | ||
} | ||
} |
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,64 @@ | ||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; | ||
SET time_zone = "+00:00"; | ||
CREATE DATABASE IF NOT EXISTS `uniber` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; | ||
USE `uniber`; | ||
|
||
/* Remove the user if they already exist */ | ||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI'; | ||
DROP PROCEDURE IF EXISTS uniber.drop_user_if_exists ; | ||
DELIMITER $$ | ||
CREATE PROCEDURE uniber.drop_user_if_exists() | ||
BEGIN | ||
DECLARE foo BIGINT DEFAULT 0 ; | ||
SELECT COUNT(*) | ||
INTO foo | ||
FROM mysql.user | ||
WHERE User = 'uniber' and Host = 'localhost'; | ||
IF foo > 0 THEN | ||
DROP USER 'uniber'@'localhost' ; | ||
END IF; | ||
END ;$$ | ||
DELIMITER ; | ||
CALL uniber.drop_user_if_exists() ; | ||
DROP PROCEDURE IF EXISTS uniber.drop_users_if_exists ; | ||
SET SQL_MODE=@OLD_SQL_MODE ; | ||
FLUSH PRIVILEGES; | ||
|
||
/* And make a new one */ | ||
CREATE USER 'uniber'@'localhost' IDENTIFIED BY 'uniber'; | ||
GRANT ALL PRIVILEGES ON uniber.* TO 'uniber'@'localhost' WITH GRANT OPTION; | ||
|
||
/* Examples left here for new tables | ||
DROP TABLE IF EXISTS `car_park_info`; | ||
CREATE TABLE IF NOT EXISTS `car_park_info` ( | ||
`id` int(11) NOT NULL, | ||
`car_park` int(11) NOT NULL, | ||
`available` int(11) NOT NULL, | ||
`time` datetime NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
DROP TABLE IF EXISTS `car_parks`; | ||
CREATE TABLE IF NOT EXISTS `car_parks` ( | ||
`id` int(11) NOT NULL, | ||
`name` text NOT NULL, | ||
`data_name` text NOT NULL, | ||
`casual` tinyint(1) NOT NULL DEFAULT '1', | ||
`active` tinyint(1) NOT NULL DEFAULT '1' | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
ALTER TABLE `car_parks` | ||
ADD PRIMARY KEY (`id`); | ||
ALTER TABLE `car_park_info` | ||
ADD PRIMARY KEY (`id`), | ||
ADD KEY `car_park` (`car_park`); | ||
ALTER TABLE `car_parks` | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; | ||
ALTER TABLE `car_park_info` | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; | ||
ALTER TABLE `car_park_info` | ||
ADD CONSTRAINT `car_park_info_ibfk_1` FOREIGN KEY (`car_park`) REFERENCES `car_parks` (`id`); | ||
*/ |
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,13 @@ | ||
var mysql = require('mysql'); | ||
|
||
var config = require('../config'); | ||
|
||
var conn = null; | ||
|
||
module.exports = function() { | ||
if (!conn) { | ||
var conn = mysql.createConnection(config.mysql); | ||
} | ||
|
||
return conn; | ||
} |
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,32 @@ | ||
{ | ||
"name": "uniber", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"start": "npm run tsc && node ./bin/www", | ||
"tsc": "tsc", | ||
"typings": "typings", | ||
"postinstall": "typings install" | ||
}, | ||
"dependencies": { | ||
"angular2": "^2.0.0-beta.11", | ||
"body-parser": "~1.13.2", | ||
"cookie-parser": "~1.3.5", | ||
"debug": "~2.2.0", | ||
"ejs": "^2.4.1", | ||
"express": "~4.13.1", | ||
"jade": "~1.11.0", | ||
"morgan": "~1.6.1", | ||
"mysql": "^2.10.2", | ||
"serve-favicon": "~2.3.0", | ||
"es6-promise": "^3.0.2", | ||
"es6-shim": "^0.35.0", | ||
"reflect-metadata": "0.1.2", | ||
"rxjs": "5.0.0-beta.2", | ||
"zone.js": "0.6.4" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^1.8.9", | ||
"typings": "^0.7.9" | ||
} | ||
} |
Oops, something went wrong.