-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·51 lines (43 loc) · 1.47 KB
/
server.js
File metadata and controls
executable file
·51 lines (43 loc) · 1.47 KB
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
const express = require('express');
const morgan = require('morgan');
const path = require('path');
const app = express();
const port = process.env.PORT || 3000;
const bodyParser = require('body-parser');
const axios = require('axios');
const compression = require('compression');
app.use(morgan('dev'));
app.use(compression());
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(function(err, req, res, next) {
console.error(err.stack);
res.status(500).send('Something broke!');
});
// NOTE: 3001 Album Player
app.all('/artists/albums/:artistID', (req, res, next) => {
console.log('REDIRECTING TO 3001 PLAYER');
res.redirect('http://52.15.129.193/artists/albums/' + req.params.artistID);
next();
});
// NOTE: 3002 Related Artists
app.all('/artist/:id/relatedArtists', (req, res, next) => {
console.log('REDIRECTING TO 3002 RELATED ARTISTS');
res.redirect('http://18.206.245.56/artist/' + req.params.id + '/relatedArtists/');
next();
});
// NOTE: 3003 Popular Songs
app.all('/artist/:id', (req, res, next) => {
console.log('REDIRECTING TO 3003 POPULAR SONGS');
res.redirect('http://18.224.17.253/artist/' + req.params.id);
next();
});
// NOTE: 3004 Header
app.all('/artists/:artistID', (req, res, next) => {
console.log('REDIRECTING TO 3004 - HEADER');
res.redirect('http://35.172.133.115/artists/' + req.params.artistID);
next();
});
app.listen(port, () => {
console.log(`🌎 server running at: http://localhost:${port}`);
});