Add serve.js for visual test

pull/3/head
Amio 2018-07-01 16:11:23 +08:00
rodzic b098210f12
commit 4dea3f9912
1 zmienionych plików z 12 dodań i 0 usunięć

12
test/serve.js 100644
Wyświetl plik

@ -0,0 +1,12 @@
const http = require('http')
const badgen = require('..')
// @example
// http://localhost:3000/npm/v1.2.3
const serveBadge = (req, res) => {
const [ subject, status, color ] = req.url.split('/').filter(Boolean)
res.writeHead(200, { 'Content-Type': 'image/svg+xml;charset=utf-8' })
res.end(badgen({subject, status, color}))
}
http.createServer(serveBadge).listen(3000)