Now returning visit count via api get
This commit is contained in:
parent
08140742ed
commit
d8cb023765
|
@ -150,10 +150,17 @@ fastify.get('/api/:shortcode', async (req, res) => {
|
||||||
return 404;
|
return 404;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const visits = await knex.select('timestamp')
|
||||||
|
.from('visits')
|
||||||
|
.where('shortcode', '=', shortcode);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: `${config.getBaseUrl()}/${exists[0].shortcode}`,
|
url: `${config.getBaseUrl()}/${exists[0].shortcode}`,
|
||||||
shortcode: exists[0].shortcode,
|
shortcode: exists[0].shortcode,
|
||||||
target: exists[0].target
|
target: exists[0].target,
|
||||||
|
visits: visits.length
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue