diff options
author | Noah Loomans <noahloomans@gmail.com> | 2017-09-27 11:40:32 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2017-09-27 11:40:32 +0200 |
commit | 63255f8cc3922ef267d9ec0bb69e4867da991a58 (patch) | |
tree | b8fd36f8f6319a0309088bd8030f58a2aa420f77 /src/server/routes | |
parent | 4d640c00bebc1a674efdeb84a8f9ea5e6db06469 (diff) |
Add screenshot api
Diffstat (limited to 'src/server/routes')
-rw-r--r-- | src/server/routes/getSchedule.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/server/routes/getSchedule.js b/src/server/routes/getSchedule.js index f6c3cb6..cb7ad67 100644 --- a/src/server/routes/getSchedule.js +++ b/src/server/routes/getSchedule.js @@ -2,6 +2,7 @@ const express = require('express') const router = express.Router() const request = require('request') const iconv = require('iconv-lite') +const webshot = require('webshot') const getUserIndex = require('../lib/getUserIndex') const getURLOfUser = require('../lib/getURLOfUser') @@ -21,6 +22,16 @@ function getWeekNumber (target) { return 1 + Math.ceil((firstThursday - target) / 604800000) } +router.get('/:type/:value.png', function (req, res, next) { + port = process.env.PORT || 3000; + const { type, value } = req.params + const stream = webshot( + `http://localhost:${port}/get/${type}/${value}`, + { customCSS: "body { background-color: white; }" } + ) + stream.pipe(res) +}) + router.get('/:type/:value', function (req, res, next) { getUserIndex().then(users => { const { type, value } = req.params |