-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathroutes.js
54 lines (50 loc) · 926 Bytes
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// var fs = require('fs') redundant
var db = require('./data/db')
module.exports = {
getHome: getHome,
getArtwork: getArtwork,
getArtist: getArtist
}
// functions...
function getImageId () {
return {
ID: [
'1001',
'1002',
'1003',
'2001',
'2002',
'2003',
'2004',
'2005',
'3001',
'3002',
'3003',
'4001',
'5001'
]
}
}
function getHome (req, res) {
var data = getImageId()
res.render('home', data)
}
function getArtwork (req, res) {
var artworkId = Number(req.params.id)
db.readArtwork(artworkId, function (err, artworkDets) {
if (err) {
return err
}
res.render('artwork', artworkDets)
})
}
//
function getArtist (req, res) {
var artistId = Number(req.params.id)
db.readArtist(artistId, function (err, artistDets) {
if (err) {
return err
}
res.render('artist', artistDets)
})
}