From bb99c2dcd1ce89af1bc27a035be5265345d2a05f Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Sat, 21 Aug 2021 09:59:14 +0200 Subject: [PATCH] Added endpoint to query over all visited urls --- src/server.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/server.js b/src/server.js index 8698218..7d5eed0 100644 --- a/src/server.js +++ b/src/server.js @@ -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;