Now returning visit count via api get

This commit is contained in:
Nicolai Ort 2021-08-14 09:27:59 +02:00
parent 08140742ed
commit d8cb023765
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
1 changed files with 8 additions and 1 deletions

View File

@ -150,10 +150,17 @@ fastify.get('/api/:shortcode', async (req, res) => {
return 404;
}
const visits = await knex.select('timestamp')
.from('visits')
.where('shortcode', '=', shortcode);
return {
url: `${config.getBaseUrl()}/${exists[0].shortcode}`,
shortcode: exists[0].shortcode,
target: exists[0].target
target: exists[0].target,
visits: visits.length
}
});
}
});