Added delete api route
This commit is contained in:
parent
fd16b39443
commit
71fa977af4
|
@ -186,6 +186,23 @@ fastify.get('/api/:shortcode/visits', async (req, res) => {
|
|||
return visits;
|
||||
});
|
||||
|
||||
//Get url api route
|
||||
fastify.delete('/api/:shortcode', async (req, res) => {
|
||||
const shortcode = req.params.shortcode;
|
||||
|
||||
//This should never happen but better safe than 500
|
||||
if (!shortcode) {
|
||||
return 404;
|
||||
}
|
||||
|
||||
await knex('urls')
|
||||
.where('shortcode', '=', shortcode)
|
||||
.delete();
|
||||
|
||||
res.statusCode = 204;
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks for some default providers with custom url schemes (amazon and youtube r/n)
|
||||
* @param {string} target The target URL
|
||||
|
|
Loading…
Reference in New Issue