Compare commits

...

3 Commits

Author SHA1 Message Date
a62ee63c83 🚀RELEASE 0.3.0
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-18 15:22:49 +02:00
c89f2a2939
Added stats api route 2021-08-18 15:21:36 +02:00
d51c58867d
Added comments 2021-08-16 15:19:04 +02:00
3 changed files with 29 additions and 2 deletions

View File

@ -2,8 +2,19 @@
All notable changes to this project will be documented in this file. Dates are displayed in UTC. All notable changes to this project will be documented in this file. Dates are displayed in UTC.
#### [0.3.0](https://git.odit.services/kauft.es/linkylinky/compare/0.2.0...0.3.0)
- Added license [`5bb7212`](https://git.odit.services/kauft.es/linkylinky/commit/5bb7212420ba102e743d62a47074191cdb264d2a)
- Added stats api route [`c89f2a2`](https://git.odit.services/kauft.es/linkylinky/commit/c89f2a2939b658ffc688646ccce32fc0e1530583)
- Added author info [`2fa520f`](https://git.odit.services/kauft.es/linkylinky/commit/2fa520fdde1d55b2766b4b03e394e21a4f6cbae5)
- Updated readme [`2226705`](https://git.odit.services/kauft.es/linkylinky/commit/2226705e3f57d7d2f3ef5a79947c3ab44ec62c38)
- Added comments [`d51c588`](https://git.odit.services/kauft.es/linkylinky/commit/d51c58867d7508c84f26c236e38567bc6a4adbed)
#### [0.2.0](https://git.odit.services/kauft.es/linkylinky/compare/0.1.4...0.2.0) #### [0.2.0](https://git.odit.services/kauft.es/linkylinky/compare/0.1.4...0.2.0)
> 14 August 2021
- 🚀RELEASE 0.2.0 [`7293295`](https://git.odit.services/kauft.es/linkylinky/commit/72932955d15976947dd553c5deba51cbf541b215)
- Added ebay provider recognition [`12c6d7e`](https://git.odit.services/kauft.es/linkylinky/commit/12c6d7e3da5cb4de6a597b4639f313b8e4319646) - Added ebay provider recognition [`12c6d7e`](https://git.odit.services/kauft.es/linkylinky/commit/12c6d7e3da5cb4de6a597b4639f313b8e4319646)
- Ebay provider resolution [`339e2f3`](https://git.odit.services/kauft.es/linkylinky/commit/339e2f39d88d42a961e1e495f319dc0663cdc0a6) - Ebay provider resolution [`339e2f3`](https://git.odit.services/kauft.es/linkylinky/commit/339e2f39d88d42a961e1e495f319dc0663cdc0a6)
- Now recognizing with and without protocol [`1624e66`](https://git.odit.services/kauft.es/linkylinky/commit/1624e666e83e0afe346bcacb105ea1a1535f0690) - Now recognizing with and without protocol [`1624e66`](https://git.odit.services/kauft.es/linkylinky/commit/1624e666e83e0afe346bcacb105ea1a1535f0690)

View File

@ -1,6 +1,6 @@
{ {
"name": "@odit/shortener-backend", "name": "@odit/shortener-backend",
"version": "0.2.0", "version": "0.3.0",
"main": "index.js", "main": "index.js",
"license": "MIT", "license": "MIT",
"private": false, "private": false,

View File

@ -139,6 +139,20 @@ fastify.post('/api', { newUrlSchema }, async (req, res) => {
} }
}); });
//Get stats api route
fastify.get('/api/stats', async (req, res) => {
const urls = await knex.select('shortcode')
.from('urls');
const visits = await knex.select('timestamp')
.from('visits');
return {
urls: urls.length,
visits: visits.length,
}
});
//Get url api route //Get url api route
fastify.get('/api/:shortcode', async (req, res) => { fastify.get('/api/:shortcode', async (req, res) => {
const shortcode = req.params.shortcode; const shortcode = req.params.shortcode;
@ -168,6 +182,7 @@ fastify.get('/api/:shortcode', async (req, res) => {
} }
}); });
//User registration //User registration
fastify.post('/api/register', async (req, res) => { fastify.post('/api/register', async (req, res) => {
if (!config.registrationEnabled) { if (!config.registrationEnabled) {
@ -201,6 +216,7 @@ fastify.post('/api/register', async (req, res) => {
return "Done!" return "Done!"
}); });
//Anything in here has some kind of auth
fastify.after(() => { fastify.after(() => {
//Get url api route //Get url api route
fastify.get('/api/:shortcode/visits', { onRequest: fastify.basicAuth }, async (req, res) => { fastify.get('/api/:shortcode/visits', { onRequest: fastify.basicAuth }, async (req, res) => {