-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement basic nodejs server with routes
- Loading branch information
Christine Emrich
committed
Mar 12, 2017
0 parents
commit ecebd0c
Showing
7 changed files
with
109 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# http://EditorConfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{js,html,css}] | ||
indent_style = tab |
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,4 @@ | ||
{ | ||
"node": true, | ||
"esnext": true | ||
} |
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,18 @@ | ||
const channels = require('./../models/channels'); | ||
|
||
exports.getShows = function() { | ||
return channels.ids.map(function (channelId) { | ||
return exports.getShow(channelId); | ||
}); | ||
}; | ||
|
||
exports.getShow = function(channelId) { | ||
return { | ||
title: "The Title", | ||
subtitle: "The Subtitle", | ||
description: "description", | ||
channel: channelId, | ||
startTime: new Date().getTime(), | ||
endTime: new Date().getTime() | ||
}; | ||
}; |
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,10 @@ | ||
const express = require('express'); | ||
const shows = require('./routes/shows'); | ||
|
||
const app = express(); | ||
|
||
app.get('/shows', shows.findAll); | ||
app.get('/shows/:channelId', shows.findByChannel); | ||
|
||
app.listen(3000); | ||
console.log('Listening on port 3000...'); |
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,36 @@ | ||
exports.ids = [ | ||
"das_erste", | ||
"br_nord", | ||
"br_sued", | ||
"hr", | ||
"mdr_sachsen", | ||
"mdr_sachsen_anhalt", | ||
"mdr_thueringen", | ||
"ndr_hh", | ||
"ndr_mv", | ||
"ndr_nds", | ||
"ndr_sh", | ||
"rbb_berlin", | ||
"rbb_brandenburg", | ||
"sr", | ||
"swr_bw", | ||
"swr_rp", | ||
"wdr", | ||
"ard_alpha", | ||
"tagesschau24", | ||
"one", | ||
|
||
"arte", | ||
|
||
"zdf", | ||
"dreisat", | ||
"kika", | ||
"phoenix", | ||
"zdf_info", | ||
"zdf_neo", | ||
|
||
"deutsche_welle", | ||
|
||
"parlamentsfernsehen_1", | ||
"parlamentsfernsehen_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "zapp-backend", | ||
"version": "1.0.0", | ||
"description": "Program info API for German public broadcasting services.", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Christine Coenen", | ||
"license": "MIT", | ||
"dependencies": { | ||
"express": "^4.15.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const downloader = require('./../downloader/show-downloader'); | ||
|
||
exports.findAll = function(req, res) { | ||
res.send(downloader.getShows()); | ||
}; | ||
|
||
exports.findByChannel = function(req, res) { | ||
res.send([downloader.getShow(req.params.channelId)]); | ||
}; |