diff --git a/.gitignore b/.gitignore
index bebf57c1..61c93a13 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,8 @@ node_modules/
typings/
frontend/*/*.js
frontend/*/*.js.map
+frontend/*.js
+frontend/*.js.map
backend/*/*.js
backend/*/*.js.map
backend/*.js
diff --git a/backend/server.ts b/backend/server.ts
index 9dc518cb..87431f64 100644
--- a/backend/server.ts
+++ b/backend/server.ts
@@ -4,101 +4,110 @@ import * as _express from 'express';
import * as _debug from 'debug';
import * as _http from 'http';
-var debug = _debug("PiGallery2:server");
-var app = _express();
+
+export class Server {
+
+ private debug:any;
+ private app:any;
+ private server:any;
+ private port:number;
+
+ constructor(){
+
+ this.debug = _debug("PiGallery2:server");
+ this.app = _express();
+
+ if(process.env.DEBUG) {
+ var _morgan = require('morgan');
+ this.app.use(_morgan('dev'));
+ }
+
+
+ this.app.use(_express.static(__dirname +'./../frontend'));
+ this.app.use('/node_modules',_express.static(__dirname +'./../node_modules'));
+
+
+
+ // Get port from environment and store in Express.
+ this.port = Server.normalizePort(process.env.PORT || '80');
+ this.app.set('port', this.port);
+
+ // Create HTTP server.
+ this.server = _http.createServer(this.app);
+
+ //Listen on provided port, on all network interfaces.
+ this.server.listen(this.port);
+ this.server.on('error', this.onError);
+ this.server.on('listening', this.onListening);
+
+
+ }
+
+
+ /**
+ * Normalize a port into a number, string, or false.
+ */
+ private static 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.
+ */
+ private onError = (error) => {
+ if (error.syscall !== 'listen') {
+ throw error;
+ }
+
+ var bind = typeof this.port === 'string'
+ ? 'Pipe ' + this.port
+ : 'Port ' + this.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.
+ */
+ private onListening = () => {
+ var addr = this.server.address();
+ var bind = typeof addr === 'string'
+ ? 'pipe ' + addr
+ : 'port ' + addr.port;
+ this.debug('Listening on ' + bind);
+ };
+
+}
+
if(process.env.DEBUG) {
console.log("Running in DEBUG mode");
-
- import * as _morgan from 'morgan';
- app.use(_morgan('dev'));
-}
-
-
-app.use(_express.static(__dirname +'./../frontend'));
-app.use('/node_modules',_express.static(__dirname +'./../node_modules'));
-
-
-
-/**
- * Get port from environment and store in Express.
- */
-
-var port = normalizePort(process.env.PORT || '3001');
-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);
}
+new Server();
\ No newline at end of file
diff --git a/common/tsconfig.json b/common/tsconfig.json
new file mode 100644
index 00000000..c5273275
--- /dev/null
+++ b/common/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "compilerOptions": {
+ "target": "es5",
+ "sourceMap": true,
+ "module": "system",
+ "moduleResolution": "node",
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "removeComments": false
+ },
+ "exclude": [
+ "./../node_modules",
+ "./../typings"
+ ]
+}
\ No newline at end of file
diff --git a/frontend/app/app.component.ts b/frontend/app/app.component.ts
new file mode 100644
index 00000000..003e167f
--- /dev/null
+++ b/frontend/app/app.component.ts
@@ -0,0 +1,24 @@
+import { Component } from 'angular2/core';
+import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router';
+import {LoginComponent} from "./login/login.component";
+
+
+
+@Component({
+ selector: 'pi-gallery2-app',
+ template: `