Server now inserts provider on visit
This commit is contained in:
parent
f48159b31b
commit
824c109a42
|
@ -75,20 +75,24 @@ fastify.decorate('verifyJWT', function async(request, reply, done) {
|
|||
//Automagic Amazn redirects on /a/
|
||||
fastify.get('/a/:id', async (req, res) => {
|
||||
res.redirect(302, `https://amazon.de/dp/${req.params.id}`)
|
||||
await knex('visits').insert({ shortcode: req.params.id, provider: 'a' });
|
||||
})
|
||||
|
||||
//Automagic Youtube redirects on /yt/
|
||||
fastify.get('/yt/:id', async (req, res) => {
|
||||
res.redirect(302, `https://youtu.be/${req.params.id}`)
|
||||
await knex('visits').insert({ shortcode: req.params.id, provider: 'yt' });
|
||||
})
|
||||
//Automagic Youtube Playlist redirects on /ytpl/
|
||||
fastify.get('/ytpl/:id', async (req, res) => {
|
||||
res.redirect(302, `https://youtube.com/playlist?list=${req.params.id}`)
|
||||
await knex('visits').insert({ shortcode: req.params.id, provider: 'ytpl' });
|
||||
})
|
||||
|
||||
//Automagic ebay item redirects on /e/
|
||||
fastify.get('/e/:id', async (req, res) => {
|
||||
res.redirect(302, `https://ebay.de/itm/${req.params.id}`)
|
||||
await knex('visits').insert({ shortcode: req.params.id, provider: 'e' });
|
||||
})
|
||||
|
||||
//Normal shorturls
|
||||
|
@ -107,7 +111,7 @@ fastify.get('/:shortcode', async (req, res) => {
|
|||
return 404
|
||||
}
|
||||
res.redirect(302, target[0].target);
|
||||
await knex('visits').insert({ shortcode });
|
||||
await knex('visits').insert({ shortcode, provider: 'native' });
|
||||
})
|
||||
|
||||
//Create new url schema
|
||||
|
|
Loading…
Reference in New Issue