badgen.net/libs/public-handlers.js

23 wiersze
570 B
JavaScript
Czysty Zwykły widok Historia

2018-09-04 07:00:54 +00:00
const serveHandler = require('serve-handler')
const { get } = require('micro-fork')
const servePublicPages = (req, res) => {
serveHandler(req, res, { public: 'public' })
}
2018-10-17 09:47:42 +00:00
const redirectTo = (target) => {
return (req, res) => {
res.writeHead(302, { 'Location': target })
res.end()
}
}
2018-09-04 07:00:54 +00:00
module.exports = [
get('/_next/*', servePublicPages),
get('/static/*', servePublicPages),
2018-10-16 02:22:50 +00:00
get('/builder', servePublicPages),
2018-10-17 09:47:42 +00:00
get('/gallery', redirectTo('/gallery/live')),
2018-10-18 02:07:59 +00:00
get('/gallery/', redirectTo('/gallery/live')),
2018-10-17 09:47:42 +00:00
get('/gallery/*', servePublicPages)
2018-09-04 07:00:54 +00:00
]