Added endpoint to query over all visited urls

This commit is contained in:
Nicolai Ort 2021-08-21 09:59:14 +02:00
parent e8382fb579
commit bb99c2dcd1
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
1 changed files with 9 additions and 1 deletions

View File

@ -267,7 +267,7 @@ fastify.post('/api/auth/register', async (req, res) => {
//Anything in here has some kind of auth
fastify.after(() => {
//Get url api route
//Get url visits api route
fastify.get('/api/:shortcode/visits', { onRequest: fastify.auth([fastify.basicAuth, fastify.verifyJWT]) }, async (req, res) => {
const shortcode = req.params.shortcode;
@ -283,6 +283,14 @@ fastify.after(() => {
return visits;
});
//Get all visits api route
fastify.get('/api/visits', { onRequest: fastify.auth([fastify.basicAuth, fastify.verifyJWT]) }, async (req, res) => {
const visits = await knex.select('shortcode','timestamp', 'provider')
.from('visits');
return visits;
});
//Get url api route
fastify.delete('/api/:shortcode', { onRequest: fastify.auth([fastify.basicAuth, fastify.verifyJWT]) }, async (req, res) => {
const shortcode = req.params.shortcode;