-
Notifications
You must be signed in to change notification settings - Fork 0
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
Danny Koppenhagen
authored and
Danny Koppenhagen
committed
Nov 27, 2015
1 parent
be50b58
commit 40ddeb2
Showing
5 changed files
with
78 additions
and
43 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
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,10 +1,25 @@ | ||
exports.port = 4000; // port which the backend will run on | ||
/** | ||
* @desc specify the port which the app will run on | ||
*/ | ||
exports.port = 4000 | ||
|
||
exports.shoppinglist_db = 'mongodb://localhost/shoppinglist'; | ||
|
||
/* openweather configuration */ | ||
exports.weather = { | ||
apikey : 'YOUR_OPEN_WEATHER_DOT_COM_API_KEY', //set openweather.com API key if you have one | ||
culture : 'de', //set the culture (de, fr, etc.) | ||
forecastType: '' //set the forecast type (daily, etc.); or '' for 3 hours forecast | ||
}; | ||
/** | ||
* @desc configure pramaters for services | ||
* @desc set a value of a service to 'false' to disable the service | ||
* @desc set a value of a service to 'true' or to an object | ||
* with service-specific configuration to enable a service | ||
*/ | ||
exports.service = { | ||
shopping: false, | ||
/* | ||
{ | ||
db: 'mongodb://localhost/shoppinglist' | ||
}, | ||
*/ | ||
vbb: false, | ||
weather: { | ||
apikey : 'YOUR_OPEN_WEATHER_DOT_COM_API_KEY', //openweather.com API key | ||
culture : 'de', //culture (de, fr, etc.) | ||
forecastType: '' //forecast type (daily, etc.); or '' for 3 hours forecast | ||
} | ||
} |
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,16 +1,15 @@ | ||
{ | ||
"name": "infoscreen_3.0", | ||
"name": "homescreen-backend", | ||
"version": "0.0.1", | ||
"description": "The third version of the infoscreen", | ||
"description": "This is a backend for homescreen project of homescreenrocks", | ||
"main": "server.js", | ||
"author": "Danny Koppenhagen", | ||
"author": "Danny Koppenhagen, Tilmann Bach", | ||
"devDependencies": { | ||
"bluebird": "^3.0.5", | ||
"body-parser": "^1.14.1", | ||
"cors": "^2.7.1", | ||
"express": "^4.13.3", | ||
"mongoose": "^4.2.4", | ||
"mysql": "^2.9.0", | ||
"vbb": "^0.3.2" | ||
} | ||
} |
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,42 +1,64 @@ | ||
/** | ||
* @desc require packages | ||
*/ | ||
var express = require('express'); | ||
var cors = require('cors'); | ||
var bodyParser = require('body-parser'); | ||
|
||
var shoppinglist = require('./routes/shoppinglist.js'); | ||
var vbb = require('./routes/vbb.js'); | ||
var weather = require('./routes/weather.js'); | ||
|
||
var colors = require('colors'); | ||
var app = express(); | ||
var config = require("./config.js"); | ||
|
||
//CORS middleware | ||
var config = require('./config.js'); // require config | ||
|
||
/** | ||
* @desc CORS middleware | ||
*/ | ||
var allowCrossDomain = function(req, res, next) { | ||
res.header('Access-Control-Allow-Origin', '*'); | ||
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE'); | ||
res.header('Access-Control-Allow-Headers', 'Content-Type'); | ||
next(); | ||
res.header('Access-Control-Allow-Origin', '*'); | ||
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE'); | ||
res.header('Access-Control-Allow-Headers', 'Content-Type'); | ||
next(); | ||
} | ||
app.use(allowCrossDomain); | ||
app.use(bodyParser.json()); | ||
|
||
app.use( bodyParser.json() ); // to support JSON-encoded bodies | ||
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies | ||
extended: true | ||
})); | ||
|
||
console.log('Started the following REST-services:'.yellow); | ||
/** | ||
* @desc shopping list routes | ||
*/ | ||
if(config.service.shopping){ | ||
var shoppinglist = require('./routes/shoppinglist.js'); | ||
app.get('/shopping', shoppinglist.findAll); | ||
app.get('/shopping/:id', shoppinglist.findById); | ||
app.post('/shopping', shoppinglist.add); | ||
app.put('/shopping/:id', shoppinglist.update); | ||
app.delete('/shopping/:id', shoppinglist.delete); | ||
app.delete('/shopping', shoppinglist.deleteAll); | ||
console.log('- shopping-list'.green); | ||
} | ||
|
||
/* shopping list routes */ | ||
app.get('/list', shoppinglist.findAll); | ||
app.get('/list/:id', shoppinglist.findById); | ||
app.post('/list', shoppinglist.add); | ||
app.put('/list/:id', shoppinglist.update); | ||
app.delete('/list/:id', shoppinglist.delete); | ||
app.delete('/list', shoppinglist.deleteAll); | ||
/** | ||
* @desc station monitor routes | ||
*/ | ||
if(config.service.vbb){ | ||
var vbb = require('./routes/vbb.js'); | ||
app.get('/vbb/:id', vbb.getStationInfo); | ||
console.log('- vbb'.green); | ||
} | ||
|
||
/** | ||
* @desc weather routes | ||
*/ | ||
if(config.service.weather){ | ||
var weather = require('./routes/weather.js'); | ||
app.get('/weather/:id', weather.getWeatherInfo); | ||
console.log('- weather'.green); | ||
} | ||
|
||
/* station monitor routes */ | ||
app.get('/vbb/:id', vbb.getStationInfo); | ||
|
||
/* Weather */ | ||
app.get('/weather/:id', weather.getWeatherInfo); | ||
|
||
/** | ||
* @desc start server | ||
*/ | ||
app.listen(config.port); | ||
console.log("the app will run on:",config.port); | ||
console.log('Backend runs on Port:'.yellow, config.port); |