forked from TheConnMan/docker-hub-rss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (29 loc) · 1.04 KB
/
index.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
var vercel = require('./api/[username]/[repository]');
var log4js = require('log4js');
if (process.env.FLUENTD_HOST) {
var tags = (process.env.FLUENTD_TAGS ? process.env.FLUENTD_TAGS.split(',') : []).reduce((allTags, tag) => {
var pair = tag.split(':');
allTags[pair[0].trim()] = pair.length === 1 ? true : pair[1].trim();
return allTags;
}, {});
tags.function = 'DockerHubRSS';
log4js.addAppender(require('fluent-logger').support.log4jsAppender('docker-hub-rss', {
host: process.env.FLUENTD_HOST,
timeout: 3.0,
tags: tags
}));
}
var express = require('express');
var app = express();
app.use(express.static('public'));
app.get('/r/:username/:repository', function (req, res) {
res.redirect(`/${req.params.username}/${req.params.repository}.atom`);
});
app.get('/:username/:repository.atom', function (req, res) {
req.query.username = req.params.username;
req.query.repository = req.params.repository;
vercel(req, res);
});
app.listen(3000, function () {
console.log('Docker RSS Feed listening on port 3000!');
});