From d718bd188521873ae607aacea61035f6ab9dede7 Mon Sep 17 00:00:00 2001 From: Braun Patrik Date: Sat, 12 Mar 2016 12:53:19 +0100 Subject: [PATCH] Creating repository --- .gitignore | 4 ++ backend/server.js | 76 ++++++++++++++++++++++++++++ backend/server.js.map | 1 + backend/server.ts | 104 +++++++++++++++++++++++++++++++++++++++ backend/tsconfig.json | 15 ++++++ frontend/app/main.js | 16 ++++++ frontend/app/main.js.map | 1 + frontend/app/main.ts | 4 ++ frontend/index.html | 36 ++++++++++++++ package.json | 27 ++++++++++ tsconfig.json | 15 ++++++ tsd.json | 15 ++++++ 12 files changed, 314 insertions(+) create mode 100644 .gitignore create mode 100644 backend/server.js create mode 100644 backend/server.js.map create mode 100644 backend/server.ts create mode 100644 backend/tsconfig.json create mode 100644 frontend/app/main.js create mode 100644 frontend/app/main.js.map create mode 100644 frontend/app/main.ts create mode 100644 frontend/index.html create mode 100644 package.json create mode 100644 tsconfig.json create mode 100644 tsd.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1efce5b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea/ +PiGallery2.iml +node_modules/ +typings/ diff --git a/backend/server.js b/backend/server.js new file mode 100644 index 00000000..fc934be8 --- /dev/null +++ b/backend/server.js @@ -0,0 +1,76 @@ +/// +var _express = require('express'); +var _debug = require('debug'); +var _http = require('http'); +var debug = _debug("PiGallery2:server"); +var app = _express(); +if (process.env.DEBUG) { + console.log("Running in DEBUG mode"); + 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); +} diff --git a/backend/server.js.map b/backend/server.js.map new file mode 100644 index 00000000..fb7ab701 --- /dev/null +++ b/backend/server.js.map @@ -0,0 +1 @@ +{"version":3,"file":"server.js","sourceRoot":"","sources":["server.ts"],"names":["normalizePort","onError","onListening"],"mappings":"AAAA,0CAA0C;;;QAMtC,KAAK,EACL,GAAG,EAeH,IAAI,EAOJ,MAAM;IAUV;;OAEG;IAEH,uBAAuB,GAAG;QACtBA,IAAIA,IAAIA,GAAGA,QAAQA,CAACA,GAAGA,EAAEA,EAAEA,CAACA,CAACA;QAE7BA,EAAEA,CAACA,CAACA,KAAKA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA;YACdA,aAAaA;YACbA,MAAMA,CAACA,GAAGA,CAACA;QACfA,CAACA;QAEDA,EAAEA,CAACA,CAACA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;YACZA,cAAcA;YACdA,MAAMA,CAACA,IAAIA,CAACA;QAChBA,CAACA;QAEDA,MAAMA,CAACA,KAAKA,CAACA;IACjBA,CAACA;IAED;;OAEG;IAEH,iBAAiB,KAAK;QAClBC,EAAEA,CAACA,CAACA,KAAKA,CAACA,OAAOA,KAAKA,QAAQA,CAACA,CAACA,CAACA;YAC7BA,MAAMA,KAAKA,CAACA;QAChBA,CAACA;QAEDA,IAAIA,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AC,QAAQ,CAAC,MAAM,CAAC,SAAS,GAAE,mBAAmB,CAAC,CAAC,CAAC;YAIzE;;eAEG;YAEC,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC;YACrD,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAEtB;;eAEG;YAEC,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAErC;;eAEG;YAEH,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC5B,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC"} \ No newline at end of file diff --git a/backend/server.ts b/backend/server.ts new file mode 100644 index 00000000..9dc518cb --- /dev/null +++ b/backend/server.ts @@ -0,0 +1,104 @@ +/// + +import * as _express from 'express'; +import * as _debug from 'debug'; +import * as _http from 'http'; + +var debug = _debug("PiGallery2:server"); +var app = _express(); + + +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); +} + diff --git a/backend/tsconfig.json b/backend/tsconfig.json new file mode 100644 index 00000000..9adcce7b --- /dev/null +++ b/backend/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es5", + "sourceMap": false, + "module": "commonjs", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "removeComments": false + }, + "exclude": [ + "node_modules", + "typings" + ] +} \ No newline at end of file diff --git a/frontend/app/main.js b/frontend/app/main.js new file mode 100644 index 00000000..da705229 --- /dev/null +++ b/frontend/app/main.js @@ -0,0 +1,16 @@ +System.register(['angular2/platform/browser', './app.component'], function(exports_1) { + var browser_1, app_component_1; + return { + setters:[ + function (browser_1_1) { + browser_1 = browser_1_1; + }, + function (app_component_1_1) { + app_component_1 = app_component_1_1; + }], + execute: function() { + browser_1.bootstrap(app_component_1.AppComponent); + } + } +}); +//# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/frontend/app/main.js.map b/frontend/app/main.js.map new file mode 100644 index 00000000..9ff90c3c --- /dev/null +++ b/frontend/app/main.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";;;;;;;;;;;YAGA,mBAAS,CAAC,4BAAY,CAAC,CAAC"} \ No newline at end of file diff --git a/frontend/app/main.ts b/frontend/app/main.ts new file mode 100644 index 00000000..961cb4c1 --- /dev/null +++ b/frontend/app/main.ts @@ -0,0 +1,4 @@ +import { bootstrap } from 'angular2/platform/browser'; +import { AppComponent } from './app.component'; + +bootstrap(AppComponent); diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 00000000..511abde5 --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,36 @@ + + + + + + PiGallery2 + + + + + + + + + + + + + + + + +Loading... + + \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..811f5ecb --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "PiGallery2", + "version": "0.0.0", + "private": true, + "scripts": { + "start": "node ./backend/server" + }, + + "dependencies": { + "angular2": "^2.0.0-beta.9", + "debug": "^2.2.0", + "es6-promise": "^3.1.2", + "es6-shim": "^0.33.13", + "express": "^4.13.4", + "morgan": "^1.7.0", + "reflect-metadata": "^0.1.2", + "rxjs": "^5.0.0-beta.2", + "socket.io": "^1.4.5", + "zone.js": "^0.5.15" + }, + + "devDependencies": { + "typescript": "^1.8.7", + "typings": "^0.7.8", + "systemjs": "^0.19.24" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..556e1e16 --- /dev/null +++ b/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/tsd.json b/tsd.json new file mode 100644 index 00000000..b1155e72 --- /dev/null +++ b/tsd.json @@ -0,0 +1,15 @@ +{ + "version": "v4", + "repo": "borisyankov/DefinitelyTyped", + "ref": "master", + "path": "typings", + "bundle": "typings/tsd.d.ts", + "installed": { + "express/express.d.ts": { + "commit": "0d622d857f97d44ea7dcad2b3edec1f23c48fe9e" + }, + "node/node.d.ts": { + "commit": "0d622d857f97d44ea7dcad2b3edec1f23c48fe9e" + } + } +}